Boost logo

Boost :

Subject: [boost] [TTI] macro to "box" types for subsequent traits extraction?
From: Rein Halbersma (rhalbersma_at_[hidden])
Date: 2014-05-05 11:03:01


Hi everyone, this is my first post to this mailinglist, so I hope I follow
the proper conventions around here (yes, I did read the Discussion Policy).

I have a small feature request for the Type Traits Introspection library: a
macro BOOST_TTI_BOX_TYPE(U) that defines a class template box_type<T> with
a nested typedef named "type" that equals T::U.

Rationale: because box_type<T> is a metafunction that can be supplied to
mpl::eval_if, this facilitates user-defined traits that extract a nested
type U, but can fall back to a (user-defined) default type. This mimics the
C++11 allocator_traits that also provide defaults for allocators that lack
certain nested typedefs or other properties.

Small self-contained example:
http://coliru.stacked-crooked.com/a/76b9abf4aaf00350

One could probably also define similar "boxing" macros to go along with the
has_template and other introspection tools in TTI.

Would this be considered a useful feature?

Rein


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