Original post:
I am having an object in a complex project. So I may not be able to provide very detail API of all these classes, but I am trying to abstract my problem without need of detail.
First of all, the code below works fine:
auto ha = std::get< 1 >( d.data ).data;
Then I am try to have code below:
auto ha = std::get< 1 >( d.data ).data;
int ma = ha;
The compiler says
cannot convert ‘std::tuple<>’ to ‘int’ in initialization int ma = ha;
cannot convert ‘std::tuple<PointStreamColor<float> >’ to ‘int’ in initialization
This should means that ha
is a std::tuple variable. Then I have code below:
auto ha = std::get< 1 >( d.data ).data;
auto ma = std::get< 0 >( ha );
For the code above, the compiler says
no matching function for call to ‘get(std::tuple<>&)’ int ma = std::get< 0 >( ha );
I cannot understand why can't I use std::get here to reach the first element of a std::tuple? Can anyone give me some idea?
Update
Thank you all for pointing out that I should provide more info. I totally understand this before I post. But the implementation of classes here are template based, so massive and hierarchical, that I am not able to provide them all.
So I was trying to ask for any general idea that might cause failure for reaching std::tuple
element by std::get
.
Maybe the problem I am facing is not suitable for public discusstion here. I am so sorry for taking your time. I cannot delete this question now and maybe one of you can help close this question now.
Thank you for your time.