#12092 closed Feature Requests (fixed)
Request: allow std::tuple typelists in BOOST_AUTO_TEST_CASE_TEMPLATE()
Reported by: | Owned by: | Raffi Enficiaud | |
---|---|---|---|
Milestone: | Boost 1.67.0 | Component: | test |
Version: | Boost 1.61.0 | Severity: | Optimization |
Keywords: | test, tuple, mpl, vector, c++11, typelists | Cc: |
Description
At present, BOOST_AUTO_TEST_CASE_TEMPLATE
requires a Boost MPL sequence type to specify the list of types.
Please may I request that this be extended under >= C++11 compilation to also support a std::tuple<...>
type as a way of specifying the types?
I think this would be a good addition because I get the sense that std::tuple
is increasingly being preferred as a way to specify typelists (because it's standard, because it allows an arbitrary number of types out-of-the-box and because it doesn't use dummy placeholder types for absent types and so generates much simpler compiler errors).
Under the covers, this could just be implemented by converting to, say an equivalentboost::mpl::vector
. This isn't too onerous under modern C++ :
template <typename... Ts> boost::mpl::vector<Ts...> mpl_vector_of_tuple_impl_fn(const std::tuple<Ts...> &); template <typename T> using mpl_vector_of_tuple_t = decltype( mpl_vector_of_tuple_impl_fn( std::declval<T>() ) );
...which can then be used like:
using example_int_char_mpl_vec = mpl_vector_of_tuple_t< std::tuple< int, char > >;
I don't mind if users have to specify a different name (other than BOOST_AUTO_TEST_CASE_TEMPLATE
) when using std::tuple
.
Thanks very much for your time.
Change History (9)
comment:1 by , 5 years ago
comment:2 by , 5 years ago
Milestone: | To Be Determined → Boost 1.66.0 |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:4 by , 5 years ago
Milestone: | Boost 1.66.0 → Boost 1.67.0 |
---|
comment:7 by , 5 years ago
Thanks very much for this.
As I now understand it, the TMP gurus avoid using std::tuple
as a typelist because it has complex guts that needlessly eat up compiler-time for each instantiation. Instead, I think they typically just use an arbitrary empty template struct, eg:
template <typename...> struct my_typelist_wrapper {}; using a_typelist = my_typelist_wrapper<int, char>;
With this in mind, it might be nice to consider finessing the conversion to mpl::vector
so that it works from any arbitrary such typelist (including std::tuple
) :
template <template <typename...> class U, typename... Ts> boost::mpl::vector<Ts...> mpl_vector_of_typelist_impl_fn(const U<Ts...> &); template <typename T> using mpl_vector_of_typelist_t = decltype( mpl_vector_of_typelist_impl_fn( std::declval<T>() ) );
I'm sorry that I didn't suggest this earlier.
comment:8 by , 5 years ago
That is nice! However I closed this ticket, would you please just create a new one?
As a heavy user of BOOST unit test I would love to see this idea implemented.