śr., 22 sty 2020 o 14:16 anshu khare via Boost
Hi mentors
I was going through the optional library of boost. I was facing some problem in understanding the code base.
In lines from 94 to 97 in optional.hpp, the code is as follows:
struct in_place_init_if_t { Struct init_tag{}; explicit in_place_init_if_t(init_tag) {} //not able to understand this line
};
I understand that we are creating a structure in_place_init_if_t and inside that we are creating another structure init_tag and then we are calling the constructor of in_place_init_if_t.
But I am not able to understand that what does it the constructor do when we pass init_tag as an argument to it.
The only thing that boost::opitonal users are supposed to know about is that there is type `in_place_init_if_t` that is *not default constructible*, and that there is a corresponding constant of this type: `in_place_init_if`. The internal structure `init_tag` is an implementaiton detail that helps make sure that `in_place_init_if_t` is not default-constructible. Regards, &rzej;
Is it same as we are creating a structure Car and then creating another structure wheels inside it and passing wheels as an argument to the constructor of car as follows:
struct car { Struct wheels{}; explicit car(wheels) {} //not able to understand this line
};
Could you please tell what is the significance of passing wheels as an argument in this counter example?
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost