グローバル空間で BOOST_FUSION_DEFINE_STRUCT を定義する
BOOST_FUSION_DEFINE_STRUCT でクラスを定義する場合、
- 名前空間
- クラス名
- クラスのメンバ
を渡して定義するのですが、名前空間を指定しない場合(グローバル空間)もあると思います。
この場合は名前空間に BOOST_PP_EMPTY() を渡せばいいみたいです。
[ソース]
#include <boost/fusion/include/define_struct.hpp> #include <boost/fusion/include/io.hpp> #include <boost/fusion/include/as_vector.hpp> #include <string> #include <iostream> BOOST_FUSION_DEFINE_STRUCT( BOOST_PP_EMPTY(), person, (std::string, name) (int, age) ) int main(){ namespace f = boost::fusion; person mami; mami.name = "mami"; mami.age = 14; std::cout << f::as_vector(mami) << std::endl; return 0; }
[出力]
(mami 14)
[boost]
- ver 1.51.0