#include <iostream>
class NoCopyMove {
public:
NoCopyMove(int a) : a_(a), b_(a) {}
NoCopyMove(int a, int b) : a_(a), b_(b) {}
NoCopyMove(const NoCopyMove&) = delete;
NoCopyMove& operator=(const NoCopyMove&) = delete;
NoCopyMove(NoCopyMove&&) = delete;
NoCopyMove& operator=(NoCopyMove&&) = delete;
int a_;
int b_;
};
int main()
{
std::tuple<NoCopyMove, NoCopyMove> t {6, 9};
std::cout << std::get<0>(t).a_ << std::endl;
std::tuple<NoCopyMove, NoCopyMove> t2 {{6, 7}, {8, 9}};
return 0;
}
I'm trying to make a tuple of classes that has more than 2 arguments as their constructor. If there is just one constructor argument it works.
main.cpp:45:28: error: no matching constructor for initialization of 'std::tuple<NoCopyMove>'
std::tuple<NoCopyMove> t2 {{6, 7}, {8, 9}}};
^ ~~~~~~~~~~~~~~~~
Probably some kind of hint to the compiler would be needed but I have no idea how I could do that. Any kind of keyword and hint will be appreciated.
{8, 9}}};
should be{8, 9}};
(i.e. only 2}
). – CandelariacandelarioNoCopyMove
. – Schroederstd::initializer_list<std::initializer_list<int>>
or something similar which doesn't match nortuple
nor your constructor. – SwithinNoCopyMove
) do not meet requirements of this generic code. If you do not have generic code, then define struct which will be tailored to store and constructNoCopyMove
with multiple arguments. – Wane