Boost logo

Boost :

From: Brian Braatz (brianb_at_[hidden])
Date: 2005-07-27 17:40:40


Either something strange is happening with arg<> and transform or I did
not write this code correctly. ( :) )

Any help pointing me to either conclusion appreciated. The next step is
to try the same algorithm with transform_view. I really don't want a
lazy sequence (how could mother be proud?), but sometimes life is
disappointing.

Thanks Guys.

CODE:

struct print_type
{
        std::ostream & m_os;
        print_type(std::ostream & os = std::cout)
        : m_os(os) {}
        
    template <typename T>
    void operator()(T const& v) const
    {
        m_os << "[ " << typeid(v).name() << " ] ";
    }
};

template <class seq_t>
void _print_types(const char * pHeading)
{
        std::cout << "** " << pHeading << std::endl;
        mpl::for_each<seq_t>(print_type());
        std::cout << std::endl;
}
#define print_types(seq) _print_types<seq>(#sew);

template <class T>
struct YES
{
        typedef YES type;
};
template <class T>
struct NO
{
        typedef NO type;
};

struct A{};

typedef mpl::vector<A> vec_t;

typedef mpl::transform
<
        vec_t,
        mpl::if_
        <
                boost::is_same<mpl::_1, A >,
                YES< mpl::_1 >::type,
                NO< mpl::_1 >::type
>::type
>::type result;

void test()
{
        print_types (result);
        
        /* //////////////////////////
        
        PRINTS:
        
        ** result
        [ struct NO<struct A> ]

        SHOULD PRINT:
        
        ** result
        [ struct YES<struct A> ]

        ////////////////////////////
        */
}


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk