Subject: [Boost-bugs] [Boost C++ Libraries] #10027: Allow template parameters with types rather than hardcode typename in BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE (and friends)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-05-08 23:40:27
#10027: Allow template parameters with types rather than hardcode typename in
BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE (and friends)
--------------------------------------+---------------------
Reporter: Jonas Lippuner <jonas@â¦> | Owner: djowel
Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: fusion
Version: Boost 1.55.0 | Severity: Problem
Keywords: |
--------------------------------------+---------------------
Right now, the macro `BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE` creates
{{{
template<typename A, typename B>
struct MyStruct { ... };
}}}
from
{{{
BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE(
(A)(B),
MyStruct,
(A, foo)
(B, bar)
)
}}}
But I want to put the class `template<int DIM> class Vector` into a Boost
Fusion Struct. So the struct should allow template parameters that are not
typenames. I would like to be able to write the following:
{{{
BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE(
(int DIM)(typename B),
MyStruct,
(Vector<DIM>, foo)
(B, bar)
)
// the above becomes
// template<int DIM, typename B>
// struct MyStruct { ... };
MyStruct<3, double> struct;
}}}
This does not currently work. The following is a working (but cumbersome)
workaround (using C++11):
{{{
BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE(
(DIM)(B),
MyStructImpl,
(Vector<DIM::value>, foo)
(B, bar)
)
template<int DIM>
using MyStruct = MyStructImpl<boost::mpl::int_<DIM>>;
MyStruct<3, double> struct;
}}}
Maybe for backwards compatibility my proposed version of
`BOOST_FUSION_DEFINE_TPL_STRUCT_INLINE` where template parameters are
declared as `(int DIM)(typename B)` should be named
`BOOST_FUSION_DEFINE_FLEXIBLE_TPL_STRUCT_INLINE`.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/10027> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:16 UTC