boost-mpl

How to concatenate a const char* in compile time

纵然是瞬间 提交于 2019-12-05 18:41:25
I have a vector of mpl::string. mpl::string size limit is 32 elements. Have a way to create const char* array in compile time MACRO(z,i,data) data ............. const char* array[] = { BOOST_PP_ENUM(SIZE,MACRO,mpl_vector) }; But i need get a one const char* string in compile time. How to make it? UPDATE I create an array of mpl::string in compile time. They compressed (size of every string about 25-31 with limit of 32). I may get array from it strings like //first,second string etc is mpl::c_str<mpl_string>::value const char* array_mpl_strings[] = {first_string,second_string .....}; But i need

What's the idiomatic way to traverse a boost::mpl::list?

独自空忆成欢 提交于 2019-12-05 10:12:47
问题 Edit: I've edited the sample to better resemble the problem I have, now the function depends on a regular parameter (and not only on template parameters) which means that the computations can't be made at compile time. I wrote some code with a hand written typelist and now we've started using boost and I'm trying to move it to the mpl library. I can't seem to find any decent documentation for mpl::list and I'm even failing to port the code to boost::mpl . I've got the feeling that even when

Multiple inheritance of interfaces in C++

元气小坏坏 提交于 2019-12-04 22:01:57
问题 I have an object interface and a open ended collection of interfaces that a derived object might want to support. // An object class IObject { getAttribute() = 0 } // A mutable object class IMutable { setAttribute() = 0 } // A lockable object class ILockable { lock() = 0 } // A certifiable object class ICertifiable { setCertification() = 0 getCertification() = 0 } Some derived objects might look like this: class Object1 : public IObject, public IMutable, public ILockable {} class Object2 :

How do I loop over a boost MPL list of non-default constructed classes?

↘锁芯ラ 提交于 2019-12-04 11:36:51
I have the following example: #include <iostream> #include <boost/mpl/for_each.hpp> #include <boost/mpl/list.hpp> struct one {}; struct two {}; struct three {}; struct four {}; struct five { five() = delete; }; template <typename T> void print() { std::cout << "hello " << typeid(T).name() << std::endl; } struct type_printer { template <typename T> void operator()(T) { print<T>(); } }; int main() { typedef boost::mpl::list< one, two, three, four, five >::type type_list; boost::mpl::for_each<type_list>(type_printer()); } Which works absolutely fine if I don't include the fifth object in the list

Creating all template permutations with MPL

时间秒杀一切 提交于 2019-12-04 10:52:37
问题 I have the following templated class structure struct TraitA{}; struct TraitB{}; template<typename trait> struct FunctionalityA{}; template<typename trait> struct FunctionalityB{}; template<typename Func> struct FuncUserA{}; template<typename Func> struct FuncUserB{}; template<typename fuser> struct Host{}; The Host class can now how have the following types. typedef Host<FuncUserA<FunctionalityA<TraitA> > > Host1_t; typedef Host<FuncUserA<FunctionalityA<TraitB> > > Host2_t; typedef Host

C++11 how to proxy class function having only its name and parent class?

不问归期 提交于 2019-12-04 09:08:25
I wonder if it is possible using boost::mpl/preprocessor or some noce C++11 features to create function proxy from class type and function name. Say we had: inline void set_email(const ::std::string& value); inline void set_email(const char* value); inside class Email. We know there is set_email function n it, we want to create a prox class with API like PROXY(Email, set_email, MyEmail) Email * email = new Email(); MyEmail * myEmail = new MyEmail(email); and have abilety to call any of set_email overloads.Is it possible and how to create such class that would proxy any number of overload

pretty printing boost::mpl::string<…> types in gdb

♀尐吖头ヾ 提交于 2019-12-04 06:38:59
I use boost::mpl::string<...> types extensively... enough that it would really help with debugging to have the types pretty-printed in gdb . So... instead of gdb showing the individual (multicharacter literal) components like it currently does ... boost::mpl::string<1668248165, 778856802, 778858343, ..., ..., 0, 0, 0, 0, 0, 0> It would display the equivalent string value instead ... boost::mpl::string<"The way out is through"> I've seen gdb macros and python scripts for pretty-printing STL containers in gdb , but I couldn't find one for pretty-printing boost::mpl strings. Can anyone help with

Boost.MPL and type list generation

こ雲淡風輕ζ 提交于 2019-12-04 05:19:29
Background This is for a memory manager in a game engine. I have a freelist implemented, and would like to have a compile-time list if these. (A MPL or Fusion vector, for example). The freelist 's correspond to allocation sizes, and when allocating/deallocating objects of size less than a constant, they will go to the corresponding freelist . In the end, this means small objects globally have amortized constant time allocation and constant time deallocation. (Yay.) Problem The problem is generating the types I need, so I may eventually use Fusion to instantiate those types. The types in use

What's the idiomatic way to traverse a boost::mpl::list?

时光毁灭记忆、已成空白 提交于 2019-12-03 21:47:50
Edit: I've edited the sample to better resemble the problem I have, now the function depends on a regular parameter (and not only on template parameters) which means that the computations can't be made at compile time. I wrote some code with a hand written typelist and now we've started using boost and I'm trying to move it to the mpl library. I can't seem to find any decent documentation for mpl::list and I'm even failing to port the code to boost::mpl . I've got the feeling that even when (if?) I do succeed in porting the code it will still not be idiomatic. Can' you please let me know how

Combination of types using boost::mpl

走远了吗. 提交于 2019-12-03 16:52:42
I have a list of types, from which I want to construct the list of all combinations with two elements. For example: namespace mpl = boost::mpl; typedef mpl::vector<int, long> typelist; // mpl magic... // the wanted list is equivalent to: typedef mpl::vector<pair<int, int>, pair<int, long>, pair<long, int>, pair<long, long> > combinations; Here, pair<T1,T2> could be std::pair<T1,T2> , or mpl::vector<T1,T2> . How to do this? I would also be interested in removing the duplicates when we consider that pair<T1, T2> == pair<T2, T1> . Thanks. The list of combinations of a single type int with the