Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost-users][array] Passing by reference
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-02-25 21:08:15


AMDG

Ryan McConnehey wrote:
> I'm wanting to pass a boost::array by reference to a function.
> Normally, this isn't a problem. My first approach yielded a compiler
> error stating boost::array needs template parameters. When adding the
> template parameters (approach 2) the compiler then states boost::array
> needs T to be a compile time constant. I want the function to be able
> to take different boost::array sizes. Can boost::array be passed by
> reference without knowing the size of the array at compile time? Any
> help would be great.
>
> Ryan
>
> Approach 1
> void extract (boost::array & var) {}
>
> Approach 2
> template<typename T, typename S>
> void extract (boost::array<T, S> & var) {}

Try

template<typename T, std::size_t N>
void extract(boost::array<T, N> & var) {}

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net