|
Boost : |
From: Brian Braatz (brianb_at_[hidden])
Date: 2005-07-27 18:04:27
Ok - I just fixed this- I don't understand WHY it fixed it but it did.
I moved the if_<> into a metafunction class and passed the metafunction
class to transform.
I would think that either using it inline or as a mfc would be
equivalent.
(out of curiosity)- Anyone know the answer to this why this is the case?
> -----Original Message-----
> From: Brian Braatz
> Sent: Wednesday, July 27, 2005 3:41 PM
> To: 'boost_at_[hidden]'
> Subject: MPL:Possible Placeholder problem with transform & if_ (?)
>
> 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