C++ compiler error I do not understand

I have the following situation with which I could use some enlightenment. As usual, the context is TableGen.

in class Record:

public:
using AssertionTuple = std::tuple<SMLoc, Init *, Init *>;
...
SmallVector<AssertionTuple, 0> Assertions;

then there exists:

struct RecordsEntry {
std::unique_ptr<Record> Rec;
std::unique_ptr<ForeachLoop> Loop;
std::unique_ptr<Record::AssertionTuple> Assertion;

void dump() const;

RecordsEntry() {}
RecordsEntry(std::unique_ptr<Record> Rec) : Rec(std::move(Rec)) {}
RecordsEntry(std::unique_ptr<ForeachLoop> Loop)
: Loop(std::move(Loop)) {}
RecordsEntry(std::unique_ptr<Record::AssertionTuple> Assertion) // 4th constructor
: Assertion(std::move(Assertion)) {}
};

...

bool TGParser::addEntry(RecordsEntry E) { ...

Note that I expect to create a RecordsEntry by passing an AssertionTuple to addEntry and having the 4th constructor do the trick. The other three constructors all work fine. However, when I do this:

Record::AssertionTuple tuple = std::make_tuple(ConditionLoc, Condition, Message);
addEntry(std::move(tuple));

I get this:

C:\LLVM\llvm-project\llvm\lib\TableGen\TGParser.cpp(3190): error C2664: 'bool llvm::TGParser::addEntry(llvm::RecordsEntry)': cannot convert argument 1 from 'llvm::Record::AssertionTuple' to 'llvm::RecordsEntry'
C:\LLVM\llvm-project\llvm\lib\TableGen\TGParser.cpp(3190): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
C:\LLVM\llvm-project\llvm\lib\TableGen\TGParser.cpp(344): note: see declaration of 'llvm::TGParser::addEntry'

Ah, I guess I should show the definitions of the three arguments passed to make_tuple() above:

SMLoc ConditionLoc = Lex.getLoc();
Init *Condition = ParseValue(CurRec);
Init *Message = ParseValue(CurRec);

Since there is no complaint about making the tuple, I assume those three arguments have the correct type. The problem is the 4th RecordsEntry constructor, which cannot convert the addEntry argument ‘std::move(tuple)’ to a Record::AssertionTuple, even though that’s exactly what it is.

P.S.: Regardless of what I learn here, I’m going to change the assertion tuple into a little struct, which should work fine as demonstrated by constructor 3 above.

The 4th constructor takes a (unique) pointer, not a reference, but you pass an rvalue reference.

If you really need an unique pointer, you can make one with std::make_unique.

Ah yes, I understand. Thanks!

Now I will make a struct rather than a tuple, which will be much clearer.