Boost logo

Boost :

Subject: Re: [boost] Release Managers: permission to merge small feature torelease?
From: Michel Morin (mimomorin_at_[hidden])
Date: 2013-02-18 20:29:43


John Maddock wrote:
>> No, you're not specializing a function template. You're adding an
>> overload. My standardese is rusty, but I don't think that's allowed in
>> namespace std.
>
>
> That's my understanding too: overloading std namespace functions is
> forbidden by the std. And while possibly convenient, why would one expect
> "get" to be in namespace std when array is in namespace boost?
>
> IMO the correct solution (at least as far as the std is concerned) is to
> call "get" unqualified and let ADL do it's magic.

As for ADL, function calls with explicit template arguments
are different with (ordinary) function calls without them:
To make ADL kick in when calling a function call with explicit
template arguments, a function template with the **same name**
should be visible at the point of the call. See the standard 14.8.1.6.
So we need something like this:

namespace adl_helper
{
    namespace detail
    {
        template <typename T>
        struct always_false : boost::mpl::bool_<false> {};
    }

    template <typename T>
    typename boost::enable_if<detail::always_false<T> >::type get();
}

int main()
{
    boost::array<int, 3> ar = {{1, 2, 3}};
    using adl_helper::get;
    std::cout << get<1>(ar) << std::endl;
}

Anyway, std::get overloads done in boost/array.hpp should be removed.

Regards,
Michel


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