mpl: copy algorithm question
Hello, I need to copy a range_c into a vector_c because I need to transform that sequence, and I have difficulties transforming range_c . This code works typedef boost::mpl::range_c<std::size_t, 2u, 10> range_t; typedef boost::mpl::vector_c<std::size_t> all_dims1_t; typedef boost::mpl::copy< range_t, boost::mpl::back_inserter<all_dims1_t>
::type all_dims_t;
but then I need the 10 to be a template parameter, so I wrap it in this struct template <std::size_t max_dim> struct S { typedef boost::mpl::range_c<std::size_t, 2u, max_dim> range_t; typedef boost::mpl::vector_c<std::size_t> all_dims1_t; typedef boost::mpl::copy< range_t, boost::mpl::back_inserter<all_dims1_t>
::type all_dims_t; };
The error is: error: type 'boost::mpl::copy<...>' is not derived from type 'S<max_dim>' Really strange? Regards,
Hi Hicham, On 16 May 2010 12:02, Hicham Mouline <hicham@mouline.org> wrote:
template <std::size_t max_dim> struct S { typedef boost::mpl::range_c<std::size_t, 2u, max_dim> range_t; typedef boost::mpl::vector_c<std::size_t> all_dims1_t; typedef boost::mpl::copy< range_t, boost::mpl::back_inserter<all_dims1_t>
::type all_dims_t; };
The error is: error: type 'boost::mpl::copy<...>' is not derived from type 'S<max_dim>'
Really strange?
mpl::copy<>::type is dependent on max_dim, so you need a "typename" in front of boost::mpl::copy. Cheers, Darren
From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Darren Garvey Sent: 16 May 2010 12:29 To: boost-users@lists.boost.org Subject: Re: [Boost-users] mpl: copy algorithm question
Hi Hicham,
On 16 May 2010 12:02, Hicham Mouline <hicham@mouline.org> wrote:
template <std::size_t max_dim> struct S { typedef boost::mpl::range_c<std::size_t, 2u, max_dim> range_t; typedef boost::mpl::vector_c<std::size_t> all_dims1_t; typedef boost::mpl::copy< range_t, boost::mpl::back_inserter<all_dims1_t>
::type all_dims_t; };
The error is: error: type 'boost::mpl::copy<...>' is not derived from type 'S<max_dim>'
Really strange?
mpl::copy<>::type is dependent on max_dim, so you need a "typename" in front of boost::mpl::copy.
Cheers, Darren
Indeed, thank you. Is there a simpler way for me to construct the mpl::vector than defining the range then copying it into the vector? regards,
participants (2)
-
Darren Garvey
-
Hicham Mouline