Boost Fusion Variadic User Extension

The BoostFusionVariadicUserExtension extends the BoostFusionUserExtension of BoostFusion using the variadic templates of CeePlusPlusEleven.

This makes it very easy for users to define HomogeneousContainers and HeterogeneousContainers for CeePlusPlus and also define keywords which can be used to access the members of the container.

The structure, types and keywords are defined at compile time but the contents can vary at run time.

This is an illustration of the way in which BoostFusion combines run time and compile time features.

I have done a lot of work on several versions of this extension, but in fact there are a powerful set of macros within BoostFusion which do the equivalent job. -- JohnFletcher


Implementation

BoostFusion already has an adapter for the std::tuple in CeePlusPlusEleven. If no keywords are needed this is sufficient. A variadic_tuple is build on top to provide keyword access. There are a set of default keys, first, second etc and the user can define keys which can be used.


Example

 namespace test_keys
 {
  struct Start;
  struct End;
  struct Text;
 }

int main() { using namespace test_keys; typedef boost::mpl::vector<Start, End, Text> test_key_types; typedef vtuple<std::string,std::string,std::string> test_type; std::string start("Start"), end("End"),test(" of tests of variadic tuple"); test_type test_messages(start,end,test); std::cout << "===============================================" << std::endl; std::cout << at_c<0>(test_messages) << at_key<third>(test_messages) << std::endl; std::cout << "===============================================" << std::endl; std::cout << at_c<1>(test_messages) << test_messages.any_key<Text,test_key_types>() << std::endl; std::cout << "===============================================" << std::endl; return 0; }


CategoryBoost


EditText of this page (last edited December 16, 2014) or FindPage with title or text search