Ticket #2793: template_keyword.1.patch

File template_keyword.1.patch, 1.4 KB (added by Frank Mori Hess, 14 years ago)

Patch from David Abrahams for boost/parameter/aux_/template_keyword.hpp

  • template_keyword.hpp

     
    99# include <boost/mpl/not.hpp>
    1010# include <boost/type_traits/is_convertible.hpp>
    1111# include <boost/type_traits/is_reference.hpp>
     12# include <boost/type_traits/is_function.hpp>
     13# include <boost/type_traits/is_array.hpp>
    1214
    1315namespace boost { namespace parameter {
    1416
     
    3840{
    3941    typedef Tag key_type;
    4042    typedef T value_type;
    41     typedef value_type reference;
     43
     44    // reference is needed for two reasons:
     45    //
     46    // 1. It is used in the body of arg_list<...>
     47    //
     48    // 2. It is the result of binding<...>, which we mistakenly told
     49    //    people to use instead of value_type<...> to access named
     50    //    template parameters
     51    //
     52    // It used to be that reference == value_type, but that broke when
     53    // the argument was a function or array type, because various
     54    // arg_list functions return reference.
     55    //
     56    // Simply making reference == value_type& would break all the
     57    // legacy code that uses binding<...> to access named template
     58    // parameters.
     59    typedef typename mpl::if_<
     60        mpl::or_<is_function<value_type>, is_array<value_type> >
     61      , value_type&
     62      , value_type>::type reference;
    4263};
    4364
    4465}} // namespace boost::parameter