У меня есть шаблонный класс, который содержит кортеж. < /p>
template
class Foo
{ ... };
Как я могу применить ограничение на типы, содержащиеся в пакете параметров -параметров?template < template class... SomeTypes>
class Bar
{ ... };
< /code>
Вот более конкретный случай того, что я ищу. Код не должен (и не) компилировать, потому что foob не является заполненным. Я надеюсь, что смогу добавить какое -то предложение «Требуется к Foocontainer , что дало бы гораздо более четкую ошибку».
#include
#include
template
class Foo
{
};
template
class FooA : public Foo
{
public:
int some_data {0};
void DoSomething()
{
some_data++;
}
};
template
class FooB : public Foo
{
public:
// non-copyable object
FooB() = default;
FooB( const FooB& ) = delete;
FooB& operator=( const FooB& ) = delete;
~FooB() = default;
int some_data {0};
void DoSomething()
{
some_data++;
}
};
template < template class... SomeTypes>
// requires (std::copyable) ???
class FooContainer
{
public:
std::tuple my_tuple;
template
void DoAllThings()
{
}
template
void DoAllThings()
{
std::get(my_tuple).DoSomething();
DoAllThings();
}
};
using MyContainer = FooContainer;
int main()
{
MyContainer my_bar;
my_bar.DoAllThings();
MyContainer my_bar2 = my_bar;
}
Подробнее здесь: https://stackoverflow.com/questions/795 ... meter-pack