Is there a reason std::make_tuple
does not accept parameters that are list initialized objects?
#include <string>
#include <map>
#include <cstdint>
class FileInfo
{
public:
FileInfo() = default;
FileInfo(const std::string &name, uint64_t size) : mName(name), mSize(size) { }
bool operator == (const FileInfo& other) const
{
return mName == other.mName;
}
private:
std::string mName;
uint64_t mSize = 0;
};
void function(FileInfo fileInfo) { }
using Modifications = std::map<std::string, std::tuple<std::string, FileInfo, FileInfo>>;
int main(int argc, char *argv[])
{
Modifications modifications{
{ "f1", std::make_tuple("changed", FileInfo{ "f1", 1 }, FileInfo{ "f1", 2 }) },
{ "f2", std::make_tuple("removed", FileInfo{ "f2", 1 }, FileInfo{}) },
{ "f3", std::make_tuple("added", FileInfo{}, { "f3", 2 }) } // Error
};
function({ "f3", 2 }); // OK
return 0;
}
The third pair from the map gives the following error:
Error C2660 'std::make_tuple': function does not take 3 arguments
This error makes no sense to me. Why does't std::make_tuple
accept the third parameter when I explicitly declared the type of Modifications
as being std::map<std::string, std::tuple<std::string, FileInfo, FileInfo>>
? Is there a compiler limitation or this was simply omitted from standard?
Note: this question is not related to constructing tuple from braced list: initialize-an-stdarray-of-tuples-with-curly-braces