串联的boost :: MPL ::字符串 [英] concatenate boost::mpl::string

查看:196
本文介绍了串联的boost :: MPL ::字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何可以连接的boost :: MPL :: string的?
下面code产生错误:

 的#include<&iostream的GT;
#包括LT&;提升/ MPL / vector.hpp>
#包括LT&;提升/ MPL / string.hpp>
#包括LT&;提升/ MPL / fold.hpp>
#包括LT&;提升/ MPL / placeholders.hpp>
#包括LT&;提升/ MPL / push_back.hpp>TYPEDEF提振:: MPL ::矢量<
   提高:: MPL ::字符串<'AB'>中
   提高:: MPL ::字符串<CD>中
   提高:: MPL ::字符串<EF>
> SLIST;TYPEDEF提振:: MPL ::折叠<
   SLIST,
   提高:: MPL ::字符串<>中
   提高:: MPL ::的push_back<提高:: MPL :: _ 1,提振:: MPL :: _ 2 - ;
> :: string类型;诠释主(){
   性病::法院LT&;<提高:: MPL :: c_str<串GT; ::值<<的std :: ENDL;
}

完整的源代码在这里: http://liveworkspace.org/$c$c/31902a4b1b0831d054119bc0b8923cb6
错误:


  3:0

在文件从source.cpp包括:
  string.hpp:在实例
  提振:: MPL :: push_back_impl<
          提高:: MPL :: String_tag的


  
  

    

::申请,提振:: MPL ::字符串< 24930>>':
    提升/ MPL / push_back.hpp:32:1:结果
    从实例
    提振:: MPL ::的push_back<
            提高:: MPL ::字符串<>,提振:: MPL ::字符串< 24930>
    升压/ MPL / aux_ / has_​​type.hpp:20:1:结果
    从'常量布尔实例
    提高:: MPL :: AUX :: has_​​type<
            提高:: MPL ::的push_back,
    提高:: MPL ::字符串< 24930>>
    MPL _ :: bool_
    ::值升压/ MPL / aux_ / has_​​type.hpp:20:1:结果
    从实例
    提振:: MPL :: AUX :: has_​​type<
            提高:: MPL ::的push_back,
    提高:: MPL ::字符串< 24930>>
    MPL _ :: bool_
    升压/ MPL / AUX _ / preprocessed / GCC / quote.hpp:56:5:
    从助推实例:: MPL :: quote2<
            提高:: MPL ::的push_back
    ::申请,提振:: MPL ::字符串< 24930>>
    提升/ MPL / AUX _ / preprocessed / GCC / apply_wrap.hpp:49:1:
    从实例
    提振:: MPL :: apply_wrap2<
            提高:: MPL :: quote2,
    提高:: MPL ::字符串<>
    提高:: MPL ::字符串< 24930>
    升压/ MPL / AUX _ / preprocessed / GCC / bind.hpp:207:21:
    从助推实例:: MPL :: bind2<
            提高:: MPL :: quote2,
    MPL _ ::精氨酸&。1>,MPL _ ::精氨酸2>
    ::申请,提振:: MPL ::字符串< 24930>>
    提升/ MPL / AUX _ / preprocessed / GCC / apply_wrap.hpp:49:1:
    从实例
    提振:: MPL :: apply_wrap2<
            提高:: MPL ::保护<
                提高:: MPL :: bind2,
    MPL _ ::精氨酸&。1>,MPL _ ::精氨酸2>> 0
    ,提振:: MPL ::字符串<>,提振:: MPL ::字符串< 24930>
    升压/ MPL / AUX _ / preprocessed / GCC / apply.hpp:73:1:
    从助推实例:: MPL :: apply2<
            提高:: MPL ::的push_back,
    MPL _ :: ARG 2>>,提振:: MPL ::字符串<>
    提高:: MPL ::字符串< 24930>
    升压/ MPL / AUX _ / preprocessed / GCC / fold_impl.hpp:87:85:
    从实例
    提振:: MPL :: AUX :: fold_impl<
            3,提振:: MPL :: v_iter<
                提高:: MPL :: vector的,
    提高:: MPL ::字符串< 25444>,
    提高:: MPL ::字符串< 25958>>,0L
    ,提振:: MPL :: v_iter<
                提高:: MPL :: vector的,
    提高:: MPL ::字符串< 25444>,
    提高:: MPL ::字符串< 25958>>,3升
    ,提振:: MPL ::字符串<>,提振:: MPL ::的push_back,
    MPL _ ::精氨酸2>>
    升压/ MPL / fold.hpp:39:18:从实例化'的boost :: MPL ::折叠<
            提高:: MPL :: vector的,
    提高:: MPL ::字符串< 25444>,
    提高:: MPL ::字符串< 25958>>
          ,提振:: MPL ::字符串<>,提振:: MPL ::的push_back,
    MPL _ ::精氨酸2>>
    source.cpp:18:2:207:53:错误从这里string.hpp实例:
    价值是不是会员
    提振:: MPL ::字符串< 24930>在文件
    从包括
    升压/ MPL / back_inserter.hpp:18:0,从
    升压/ MPL / aux_ / inserter_algorithm.hpp:18,
    从boost / MPL / copy.hpp:20,从
    string.hpp:26,从source.cpp:3:
    提升/ MPL / push_back.hpp:在
    实例化
    提振:: MPL ::的push_back<
            提高:: MPL ::的push_back,
    提高:: MPL ::字符串< 24930>>
    提高:: MPL ::字符串< 25444>
    ':升压/ MPL / aux_ / has_​​type.hpp:20:1:结果
    从'常量布尔实例
    提高:: MPL :: AUX :: has_​​type<
            提高:: MPL ::的push_back<
                提高:: MPL ::的push_back,
    提高:: MPL ::字符串< 24930>>
    提高:: MPL ::字符串< 25444>
    ,MPL _ :: bool_
    ::值升压/ MPL / aux_ / has_​​type.hpp:20:1:结果
    从实例
    提振:: MPL :: AUX :: has_​​type<
            提高:: MPL ::的push_back<
                提高:: MPL ::的push_back,
    提高:: MPL ::字符串< 24930>>
    提高:: MPL ::字符串< 25444>
    ,MPL _ :: bool_
    升压/ MPL / AUX _ / preprocessed / GCC / quote.hpp:56:5:
    从助推实例:: MPL :: quote2<
            提高:: MPL ::的push_back


  

解决方案

 的#include<&iostream的GT;
#包括LT&;提升/ MPL / vector.hpp>
#包括LT&;提升/ MPL / string.hpp>
#包括LT&;提升/ MPL / fold.hpp>
#包括LT&;提升/ MPL / front.hpp>
#包括LT&;提升/ MPL / deref.hpp>
#包括LT&;提升/ MPL / placeholders.hpp>
#包括LT&;提升/ MPL / push_back.hpp>使用名字空间boost;TYPEDEF提振:: MPL ::矢量<
   提高:: MPL ::字符串<'一','B'>中
   提高:: MPL ::字符串<'C','D'>中
   提高:: MPL ::字符串<'E','F'>
> SLIST;
TYPEDEF提振:: MPL :: reverse_fold<
   SLIST,
   MPL ::字符串<>中
   提高:: MPL ::复制< MPL :: _ 1,MPL :: back_inserter< MPL :: _ 2 - ; >
> :: string类型;诠释主(){
   性病::法院LT&;<提高:: MPL :: c_str<串GT; ::值<<的std :: ENDL;
}

How I can concatenate boost::mpl::string? The following code produce errors:

#include <iostream>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/string.hpp>
#include <boost/mpl/fold.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/mpl/push_back.hpp>

typedef boost::mpl::vector<
   boost::mpl::string<'ab'>,
   boost::mpl::string<'cd'>,
   boost::mpl::string<'ef'>
> slist;

typedef boost::mpl::fold<
   slist,
   boost::mpl::string<>,
   boost::mpl::push_back<boost::mpl::_1, boost::mpl::_2>
>::type string;

int main() {
   std::cout << boost::mpl::c_str<string>::value << std::endl;
}

full source here: http://liveworkspace.org/code/31902a4b1b0831d054119bc0b8923cb6 errors:

In file included from source.cpp:3:0: string.hpp: In instantiation of 'boost::mpl::push_back_impl< boost::mpl::string_tag

::apply, boost::mpl::string<24930> >': boost/mpl/push_back.hpp:32:1:
instantiated from 'boost::mpl::push_back< boost::mpl::string<>, boost::mpl::string<24930> ' boost/mpl/aux_/has_type.hpp:20:1:
instantiated from 'const bool boost::mpl::aux::has_type< boost::mpl::push_back, boost::mpl::string<24930> >, mpl_::bool_ ::value' boost/mpl/aux_/has_type.hpp:20:1:
instantiated from 'boost::mpl::aux::has_type< boost::mpl::push_back, boost::mpl::string<24930> >, mpl_::bool_ ' boost/mpl/aux_/preprocessed/gcc/quote.hpp:56:5: instantiated from 'boost::mpl::quote2< boost::mpl::push_back ::apply, boost::mpl::string<24930> >' boost/mpl/aux_/preprocessed/gcc/apply_wrap.hpp:49:1: instantiated from 'boost::mpl::apply_wrap2< boost::mpl::quote2, boost::mpl::string<>, boost::mpl::string<24930> ' boost/mpl/aux_/preprocessed/gcc/bind.hpp:207:21: instantiated from 'boost::mpl::bind2< boost::mpl::quote2, mpl_::arg<1>, mpl_::arg<2> ::apply, boost::mpl::string<24930> >' boost/mpl/aux_/preprocessed/gcc/apply_wrap.hpp:49:1: instantiated from 'boost::mpl::apply_wrap2< boost::mpl::protect< boost::mpl::bind2, mpl_::arg<1>, mpl_::arg<2> >, 0 , boost::mpl::string<>, boost::mpl::string<24930> ' boost/mpl/aux_/preprocessed/gcc/apply.hpp:73:1: instantiated from 'boost::mpl::apply2< boost::mpl::push_back, mpl_::arg<2> >, boost::mpl::string<>, boost::mpl::string<24930> ' boost/mpl/aux_/preprocessed/gcc/fold_impl.hpp:87:85: instantiated from 'boost::mpl::aux::fold_impl< 3, boost::mpl::v_iter< boost::mpl::vector, boost::mpl::string<25444>, boost::mpl::string<25958> >, 0l , boost::mpl::v_iter< boost::mpl::vector, boost::mpl::string<25444>, boost::mpl::string<25958> >, 3l , boost::mpl::string<>, boost::mpl::push_back, mpl_::arg<2> > ' boost/mpl/fold.hpp:39:18: instantiated from 'boost::mpl::fold< boost::mpl::vector, boost::mpl::string<25444>, boost::mpl::string<25958> > , boost::mpl::string<>, boost::mpl::push_back, mpl_::arg<2> > ' source.cpp:18:2: instantiated from here string.hpp:207:53: error: 'value' is not a member of 'boost::mpl::string<24930>' In file included from boost/mpl/back_inserter.hpp:18:0, from boost/mpl/aux_/inserter_algorithm.hpp:18, from boost/mpl/copy.hpp:20, from string.hpp:26, from source.cpp:3: boost/mpl/push_back.hpp: In instantiation of 'boost::mpl::push_back< boost::mpl::push_back, boost::mpl::string<24930> >, boost::mpl::string<25444> ': boost/mpl/aux_/has_type.hpp:20:1:
instantiated from 'const bool boost::mpl::aux::has_type< boost::mpl::push_back< boost::mpl::push_back, boost::mpl::string<24930> >, boost::mpl::string<25444> , mpl_::bool_ ::value' boost/mpl/aux_/has_type.hpp:20:1:
instantiated from 'boost::mpl::aux::has_type< boost::mpl::push_back< boost::mpl::push_back, boost::mpl::string<24930> >, boost::mpl::string<25444> , mpl_::bool_ ' boost/mpl/aux_/preprocessed/gcc/quote.hpp:56:5: instantiated from 'boost::mpl::quote2< boost::mpl::push_back

解决方案

#include <iostream>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/string.hpp>
#include <boost/mpl/fold.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/deref.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/mpl/push_back.hpp>

using namespace boost;

typedef boost::mpl::vector<
   boost::mpl::string<'a','b'>,
   boost::mpl::string<'c','d'>,
   boost::mpl::string<'e','f'>
> slist;


typedef boost::mpl::reverse_fold<
   slist,
   mpl::string<>,
   boost::mpl::copy<mpl::_1, mpl::back_inserter<mpl::_2> >
>::type string;

int main() {
   std::cout << boost::mpl::c_str<string>::value << std::endl;
}

这篇关于串联的boost :: MPL ::字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆