Boost logo

Boost :

Subject: Re: [boost] Anyone have access to Sun Studio 12 compiler?
From: David Abrahams (dave_at_[hidden])
Date: 2010-10-21 07:49:29


At Wed, 20 Oct 2010 12:08:28 -0700,
Marshall Clow wrote:
>
> Yeah - it's complaining about a method in boost::array:
>
> // Specific for boost::array: simply returns its elems data member.
> template <typename T, std::size_t N>
> T(&get_c_array(boost::array<T,N>& arg))[N]
> {
> return arg.elems;
> }
>
> I don't see any subscript operators there at all. ;-)
> I suspect that this is a limitation of the compiler.

My guess is it can't parse the function-returning-reference-to-array
syntax. You can try this instead:

    namespace detail
    {
        template <typename T, std::size_t N> struct c_array
        {
            typedef T[N] type;
        };
    }

    // Specific for boost::array: simply returns its elems data member.
    template <typename T, std::size_t N>
    typename detail::c_array<T,N>::type& get_c_array(boost::array<T,N>& arg)
    {
        return arg.elems;
    }
         
HTH,

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

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