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() );
    }

  • 相关阅读:
    day32-python阶段性复习六
    golang 项目中坑
    golang crawler
    router
    golang in ubuntu
    go channel 案例分析
    go channel learning
    bee go + mgo
    URL escape and unescape
    [转]good sample of Go
  • 原文地址:https://www.cnblogs.com/cutepig/p/1620940.html
Copyright © 2011-2022 走看看