Opened 12 years ago
Closed 12 years ago
#4296 closed Feature Requests (fixed)
has_iterator, has_const_iterator metafunctions
Reported by: | Tomas Puverle (tomas dot puverle at morganstanley dot com) | Owned by: | Neil Groves |
---|---|---|---|
Milestone: | Boost 1.46.0 | Component: | range |
Version: | Boost 1.44.0 | Severity: | Not Applicable |
Keywords: | has_iterator, has_const_iterator | Cc: |
Description
This function is useful when using enable_if/disable_if for distinguishing between plain types and ranges of types.
Ideally, this would be added as an include to boost/range/metafunctions.hpp.
Code and test case attached. Tested against boost 1.43.0 with MSVC and gcc 4.2.
Attachments (1)
Change History (4)
by , 12 years ago
Attachment: | boost.range.zip added |
---|
comment:1 by , 12 years ago
This would be better implemented as
BOOST_MPL_HAS_XXX_TRAIT_DEF(type); template<class T> struct has_iterator : has_type<boost::range_iterator<T> > {}; template<class T> struct has_const_iterator : has_type<boost::range_const_iterator<T> > {};
comment:2 by , 12 years ago
Status: | new → assigned |
---|
comment:3 by , 12 years ago
Milestone: | Boost 1.44.0 → Boost 1.46.0 |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
I have implemented a solution based primarily on stevens suggestion since using BOOST_MPL_HAS_XX_TRAIT_DEF improves compiler support.
I have chosen to implement this using enable_if to select a base class since this works better on many compilers (due to the base class being dependent on the template parameters) than the snippet posted above.
A patch for boost range with two new metafunctions and a test case.