zoukankan      html  css  js  c++  java
  • testPrintSeq

    #include <boost/mpl/range_c.hpp>
    #include <boost/mpl/vector.hpp>
    #include <boost/mpl/for_each.hpp>
    #include "boost/mpl/is_sequence.hpp"
    //#include <boost/mpl/if.hpp>
    #include <iostream>

    template <bool IsSeq = true>
    struct Print
    {
        template< typename U >
        void operator()(U x)
        {
            std::cout << "Seq( ";
            boost::mpl::for_each<U> ( value_printer() );
            std::cout << ")";
        }
    };

    template <>
    struct Print<false>
    {
        template< typename U >
        void operator()(U x)
        {
             std::cout << x << ' ';
        }
    };

    struct value_printer
    {
        template< typename U > void operator()(U x)
        {
            typedef Print< boost::mpl::is_sequence<U>::value > print;;
            //typedef boost::mpl::if_< boost::mpl::is_sequence<U>, printSeq, printItem>::type print;
            print()(x);
        }
    };

    void testPrintSeq()
    {
        typedef boost::mpl::range_c<int,0,10> R1;
        typedef boost::mpl::range_c<int,5,10> R2;
        typedef boost::mpl::vector< R1, R2 >  V;

        value_printer()( V() );
    }

  • 相关阅读:
    jquery autocomplete
    hibernate 数据缓存
    Python变量类型
    Python基础语法
    Python环境搭建
    Python简介
    python下载地址
    第十、十一章,软件测试和软件演化
    第九章,软件实现
    第八章,面向对象设计
  • 原文地址:https://www.cnblogs.com/cutepig/p/1620940.html
Copyright © 2011-2022 走看看