Boost logo

Boost :

From: Steven Watanabe (steven_at_[hidden])
Date: 2007-08-25 12:00:28


AMDG

Ion Gaztañaga <igaztanaga <at> gmail.com> writes:

> before
>
> class my_value_traits
> {
> node_ptr to_node_ptr(value_type &val)
> //...
> };
>
> after
>
> class my_value_traits
> {
> template<class Container>
> node_ptr to_node_ptr(value_type &val, const Container& cont)
> //...
> };
>
> So if there is any metaprogramming hack (if increases compilation time
> too much, forget it ) I would like to receive suggestions.
>

typedef char no;
struct yes { no dummy[2]; };

template<class T>
yes convert_result(const T&);

no convert_result(const no&);

template<class T>
T make();

template<class Base>
struct has_plain_to_node_ptr_impl : Base {
    no to_node_ptr(...);
    using Base::to_node_ptr;
};

template<class T>
struct has_plain_to_node_ptr {
    enum { value =
        (sizeof(convert_result(
            has_plain_to_node_ptr_impl<T>::to_node_ptr(
                make<const value_type&>()
         ))) ==
         sizeof(yes))};
};

In Christ,
Steven Watanabe


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