Boost logo

Boost Users :

Subject: [Boost-users] Boost Variant Type Interfaces
From: Ali Nakipoglu (ali.nakipoglu_at_[hidden])
Date: 2016-02-09 09:21:56


Hi,

In our project we are using boost, boost.variant very extensively. We was using methods provided by the library to interface with Variant types. Mainly : get<T>( variant ) for accessing stored values and variant.which() == Index for checking currently stored type.

Overtime we realized we can improve this as : variant.getT() for accessing stored values much more nicer to write and variant.isT() or variant.which() == WHICH_T for checking currently stored type which does not depend on order of template paramters in the Variant definition. 

Also in some cases we wanted to be able to add type specific methods for example in our case we are using subscript operator to access recursively stored Variants variant[ "a" ].isT() or variant[ 0 ].asT()

We generalized this solution for our project and published at https://github.com/FictionIO/WrappedVariant

I would like to hear your comments. Do you think its a correct approach or useful? Any suggestions are welcome! 

Kind Regards,

Ali



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net