Вот код:
Код: Выделить всё
struct Op1WithArg
{
Op1WithArg(int){}
};
struct Op2WithArg
{
Op2WithArg(std::string){}
};
struct OpWithoutArg
{
OpWithoutArg(){}
};
template
struct OpsSequence {
using OpTuple = std::tuple;
template
OpsSequence(Args... args)
: mOps{args...}
{}
OpTuple mOps;
};
void TestSequenceWithOpWithoutArg()
{
// This works
using SequenceType = OpsSequence;
SequenceType sequence{};
}
void TestSequenceWithTwoOpsWithArg()
{
// This works
using SequenceType = OpsSequence;
SequenceType sequence{1, "Hello"};
}
void TestSequenceWithOneOpWithArgAndOneWithout()
{
// This fails to compile
using SequenceType = OpsSequence;
SequenceType sequence{1,{}};
}
Код: Выделить всё
|| [ 50%] Building CXX object CMakeFiles/tsconv_tests.dir/tests/tsconv_tests.cpp.o
|| /home/anders/src/tsconv/tests/tsconv_tests.cpp: In function ‘void tsconv::TestSequenceWithOneOpWithArgAndOneWithout()’:
tests/tsconv_tests.cpp|1014 col 31| error: no matching function for call to ‘tsconv::OpsSequence::OpsSequence(
)’
|| 1014 | SequenceType sequence{1,{}};
|| | ^
tests/tsconv_tests.cpp|989 col 5| note: candidate: ‘tsconv::OpsSequence::OpsSequence(Args ...) [with Args = {}; Ops = {tsconv::Op1WithArg, tsconv::OpWithoutArg}]’
|| 989 | OpsSequence(Args... args)
|| | ^~~~~~~~~~~
tests/tsconv_tests.cpp|989 col 5| note: candidate expects 0 arguments, 2 provided
tests/tsconv_tests.cpp|985 col 8| note: candidate: ‘constexpr tsconv::OpsSequence::OpsSequence(const tsconv::OpsSequence&)’
|| 985 | struct OpsSequence {
|| | ^~~~~~~~~~~
tests/tsconv_tests.cpp|985 col 8| note: candidate expects 1 argument, 2 provided
tests/tsconv_tests.cpp|985 col 8| note: candidate: ‘constexpr tsconv::OpsSequence::OpsSequence(tsconv::OpsSequence&&)’
tests/tsconv_tests.cpp|985 col 8| note: candidate expects 1 argument, 2 provided
gmake[2]: *** [CMakeFiles/tsconv_tests.dir/build.make|76| CMakeFiles/tsconv_tests.dir/tests/tsconv_tests.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2|83| CMakeFiles/tsconv_tests.dir/all] Error 2
gmake: *** [Makefile|101| all] Error 2
Подробнее здесь: https://stackoverflow.com/questions/787 ... -the-tuple