Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2004-09-02 07:36:09


"David Abrahams" <dave_at_[hidden]> wrote

> I had to add this to get some tests for the TMP book to pass:
>
> namespace boost { namespace lambda {
> template<int N>
> struct
> plain_return_type_2<arithmetic_action<plus_action>, char[N],
std::string> {
> typedef std::string type;
> };
> }} // namespace boost::lambda
>
> Obviously this could be generalized for basic_string and for the
> reversed arguments.

The binary_operation version would look something like this with the its
new enable_if functionality
Zounds! this enable_if is Fun :-) ... perhaps could be done in Lambda?,

    template <typename L, typename R>
    struct binary_operation<
        L,std::plus,R,
        typename boost::enable_if<
            boost::mpl::and_<
                boost::mpl::or_<
                    is_string<L>,
                    is_string<R>
>,
                is_string_concatable<L>,
                is_string_concatable<R>,
                boost::is_same<
                    typename pqs::meta::to_value_type<L>::type,
                    typename pqs::meta::to_value_type<R>::type
>
>
>::type
>{
        typedef typename boost::mpl::if_<
            is_string<L>,
            L,
            R
>::type result_type;
   };

regards
Andy Little


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