是否有一种方法来恢复原来的模板模板类嵌入在boost
Is there a way to recover original template template class enbeded in boost mpl quote?
我引用了一个模板类,将其放入mpl::vector中,这样做:
boost::mpl::vector<int, boost::mpl::quote2<std::pair>>
然后,我像这样得到第二个元素:
using A=typename boost::mpl::at<T, boost::mpl::int_<2>>::type;
我现在需要将原始模板类传递给这样的类:
template<class A, template<class, class> class C>
class B{
C<A, B*> _c;
};
我尝试使用apply或bind,但无法让B接受第二个参数。
我得到这样的错误:
error: template argument for template template parameter must be a class template or type alias template
编辑:示例代码:
#include <boost/mpl/vector.hpp>
#include <boost/mpl/quote.hpp>
#include <boost/mpl/at.hpp>
template<class, class> class A{};
template<class A, template<class, class> class C>
class B{
C<A, B*> _c;
};
using T=boost::mpl::vector<int, boost::mpl::quote2<A>> ;
using T1=typename boost::mpl::at<T, boost::mpl::int_<0>>::type;
using T2=typename boost::mpl::at<T, boost::mpl::int_<1>>::type;
int main(){
B<T1, T2> b;
return 0;
}
我:
error: template argument for template template parameter must be a class template or type alias template B<T1, T2> b;
MPL在很大程度上仍然是一个c++ 03库,你正试图让它生成一些在c++ 11之前概念上不存在的东西。我怀疑让quote
在这种情况下工作是语法的巧合,而不是预期的功能。
下面的代码可以在VC2013中成功编译:
#include <boost/mpl/vector.hpp>
#include <boost/mpl/quote.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/at.hpp>
template<class, class> class A{};
template<class A, template<class, class> class C>
class B{
C<A, B*> _c;
};
using T = boost::mpl::vector < int, boost::mpl::quote2<A> > ;
using T1 = boost::mpl::at<T, boost::mpl::int_<0>>::type;
using T2 = boost::mpl::at<T, boost::mpl::int_<1>>::type;
template<typename X1, typename X2>
using TT2 = typename boost::mpl::apply<T2, X1, X2>::type;
int main(int argc, char* argv[])
{
B<T1, TT2> b;
return 0;
}
相关文章:
- 理解boost::asio-async_read在无需读取内容时的行为
- boost::进程间消息队列引发错误
- 如何运行位于boost/libs/python/example/tutorial目录中的hello.cpp和Jamfil
- cmake如何在fedora工作站中找到boost静态库包
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- Boost Graph Library,修复节点大小
- 什么是"#include <boost/functional/hash.hpp> "?
- 基于boost的程序的静态链接——zlib问题
- C++:如何在CLion IDE中安装Boost
- C++Boost Asio Pool线程,带有lambda函数和传递引用变量
- 如何在boost beast http请求中设置http头
- Boost Spirit,获取迭代器内部语义动作
- boost::asio::steady_timer()与sleep()我应该使用哪一个
- boost::asio如何生成多个协同程序,然后加入它们
- 当我尝试使用 sstream 和分面将 Boost Time_duration转换为字符串时,我没有得到所需的格式
- Visual Studio(或任何其他工具)能否将地址解释为调用堆栈(boost上下文)的开头
- 如何使用boost::具有嵌套结构和最小代码更改的序列化
- 使用Boost Interprocess创建托管共享内存需要很长时间
- Boost::posix_time::ptime舍入到给定的分钟数
- 是否有一种方法来恢复原来的模板模板类嵌入在boost