im having some problem involving the move semantics asssociated with creating an std::tuple
from a variadic template class. This is my class (it's using Qt but that's irrelevant):
template<typename ...Ts>
class QuestionBox : public QGroupBox
{
public:
QuestionBox(const QString& question, Ts... args)
{
this->setTitle(question);
layout = new QGridLayout(this);
questionBoxElements = std::make_tuple<Ts...>(args...); //ERROR: Cannot bind rvalue ref QLabel*&& to lvalue QLabel*
auto loop = [&](auto& arg)
{
layout->addWidget(arg);
};
(loop(args), ...);
}
private:
QGridLayout* layout;
std::tuple<Ts...> questionBoxElements;
};
and it is called as so:
auto divisionSlider = new FancySlider(0, 30);
auto divisionLabel1 = new QLabel("Ranking Duration (days) : ");
auto divisionLabel2 = new QLabel("Submission Duration (days) : ");
auto competitionDivison = new QuestionBox<FancySlider*, QLabel*, QLabel*>("How will the competition be divide up?", divisionSlider, divisionLabel1, divisionLabel2);
So, everything here is working fine, except the line marked as throwing an error. All I want to be done here is create a tuple of the provided types, and provided arguments.
I've tried replacing the line causing the error with:
questionBoxElements = std::make_tuple<Ts...>(std::move(args...));
and this causes the previous errors to go away, however, then I get a new error (for some not all types):
No matching function for call to 'move(Type1*&, Type2*&)'
I'm assuming that it's because the types which throw this error do not have a move constructor implemented? Is that correct?