
Nat, thanks for the quick reply! Unfortunately, people ideally would like to work with this data types without any functions and my job is to give them type safety ;) The scenario should be: struct PossibleValues { accessor<0> value_name_0(my_union); accessor<1> value_name_1(my_union); accessor<N> value_name_n(my_union); private: discriminated_union<mpl_vector_over_pairs> my_union; }; usage: void ValueHandler(PossibleValues& ps) { if(ps.value_name_0) ps.value_name_0->netsted_value = new_value; .... } Accessor makes havy usage of mpl::if_, enable_if, etc. so that -> operator works will regular types, pointer types, types where the -> operator is defined etc... Accessor analyses the type associated with the discrminator and overloads a correct set of functions/operators for that type. For example, if a stored type is pointer -> returns the pointer itself, if the stored type is normal object the address of it is returned, but if the type contains the -> operator then the object is returned by value (in case of shared_ptr, because you can not apply the -> operator twice ->->). Thanks, Ovanes