2016-12-07 11 views
1

typename gsl::span<const gsl::byte>::const_iterator이 범위 -v3의 Readable 개념을 만족하지 않음을 발견했습니다.CommonReference가 Range-v3에서 읽기 가능에 사용하는 것은 무엇입니까?

template<typename I> 
      auto requires_(I&&) -> decltype(
       concepts::valid_expr(
        // The value, reference and rvalue reference types are related 
        // through the CommonReference concept. 
        concepts::model_of<CommonReference, reference_t<I> &&, value_t<I> &>(), 
        concepts::model_of<CommonReference, reference_t<I> &&, rvalue_reference_t<I> &&>(), 
        concepts::model_of<CommonReference, rvalue_reference_t<I> &&, value_t<I> const &>(), 
        // Experimental additional tests. If nothing else, this is a good workout 
        // for the common_reference code. 
        concepts::model_of<Same, ranges::common_reference_t<reference_t<I>, value_t<I>>, value_t<I>>(), 
        concepts::model_of<Same, ranges::common_reference_t<rvalue_reference_t<I>, value_t<I>>, value_t<I>>() 
       )); 

ranges::common_reference_tvalue_type에서 const을 제거하고 그들이 동일하지 않습니다 : 개념을 검토 한 결과,이 제약 조건을 발견했다.

CommonReference 제약 조건은 무엇을 의미합니까? 왜 Readable을 만족해야합니까?

+0

'Readable'은 포인터처럼 보이는 것들 (반복자와 스마트 포인터 같은 것)에 의해 만족됩니다. 'span'은 포인터가 아닙니다. 그것은 더 많은 '범위'와 같습니다. 나는 당신이'span'을 제약하기 위해 잘못된 개념을 사용하고 있다고 생각합니다. –

+0

그리고 기록을 위해, 마지막 두 개의 "실험적인"'Same' 제약 조건이 최신 range-v3 릴리즈에서 제거되었습니다. 업데이트해야합니다. –

+0

@EricNiebler 죄송합니다, 실수. 나는 decltype (span.cbegin())이'Readable'을 만족하지 않는다는 것을 의미합니다. – Cu2S

답변

1

문제는 GSL에 있습니다. span_iterator (https://github.com/Microsoft/GSL/blob/master/gsl/span#L145-L147)의 소스에서 :

using value_type = std::conditional_t<IsConst, std::add_const_t<typename Span::element_type>, typename Span::element_type>;

그래서 span::const_iteratorconst restrict로 value_type 있습니다. 그건 이상하고 틀렸어. 표준에 부합하지 않을 수도 있습니다. 나는 그 주장에 대한 표준 내에서 아직 확실한 증거를 찾지 못했지만 표준은 매우 암시 적이다.

template<class T> struct iterator_traits<const T*> { using difference_type = ptrdiff_t; using value_type = T; using pointer = const T*; using reference = const T&; using iterator_category = random_access_iterator_tag; };

참조 : 예를 들어, 여기에 const를 포인터에 대한 std::iterator_traits의 전문성은? value_typeconst에 대해서도 const으로 한정되지 않습니다.

+0

이것은 이제 GSL에서 수정되었습니다. –