CaseyCarter / cmcstl2

An implementation of C++ Extensions for Ranges
Other
222 stars 68 forks source link

value_type<T> does not return value type of a pointer #275

Closed uap-universe closed 5 years ago

uap-universe commented 5 years ago

The current working draft suggests (iterator.assoc.types.value_type) that value_type should have a specialization like this for pointer types:

template <class T>
struct value_type<T*>
: enable_if<is_object<T>::value, remove_cv_t<T>> { };

This specialization seems to be missing from this implementation. The below example code does only compile, if I add this specialization manually.

Full example for demonstration:

#include <experimental/ranges/concepts>
#include <experimental/ranges/iterator>

using namespace std::experimental::ranges::v1;

// Uncomment the sepcialization to make the static assert work.
/*
namespace std::experimental::ranges::v1::cursor {
template<class T>
struct value_type<T*>
: enable_if<is_object<T>::value, remove_cv_t<T>> { };
}
*/

static_assert(std::is_same_v<typename cursor::value_type_t<int*>, int>);
CaseyCarter commented 5 years ago

The current C++ working draft is N4800. It has no subclause [iterator.assoc.types.value_type]; value_type became readable_traits as part of P1037r0 "Deep Integration" which was integrated into P0896R4 "The One Ranges Proposal" that was finally merged into the C++ working draft.

std::experimental::ranges::readable_traits does have a specialization for pointer types as specified in [readable.traits] in the working draft.

(Everything in the cursor subnamespace is an implementation detail of basic_iterator from the stalled P0186 "Iterator Facade Library Proposal for Ranges".)

uap-universe commented 5 years ago

Thank you for the quick response and apologies for the inconvenience. There seems still to be too many outdated information on the internet and shame on me I did not search hard enough for the most recent stuff....