Optional library

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Optional library

Boost - Dev mailing list
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.

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