[llvm-bugs] [Bug 39619] New: iterator_traits isn't SFINAE-friendly enough

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Nov 10 12:54:13 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=39619

            Bug ID: 39619
           Summary: iterator_traits isn't SFINAE-friendly enough
           Product: libc++
           Version: 7.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: eniebler at boost.org
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

The following program fails to compile:

#include <iterator>
struct not_an_iterator {
    using iterator_category = std::input_iterator_tag;
};
std::iterator_traits<not_an_iterator> x;


The error is as follows:


In file included from <source>:1:
/opt/compiler-explorer/clang-trunk-20181110/bin/../include/c++/v1/iterator:456:29:
error: no type named 'difference_type' in 'not_an_iterator'
    typedef typename _Iter::difference_type   difference_type;
            ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
/opt/compiler-explorer/clang-trunk-20181110/bin/../include/c++/v1/iterator:467:8:
note: in instantiation of template class
'std::__1::__iterator_traits_impl<not_an_iterator, true>' requested here
    :  __iterator_traits_impl
       ^
/opt/compiler-explorer/clang-trunk-20181110/bin/../include/c++/v1/iterator:482:7:
note: in instantiation of template class
'std::__1::__iterator_traits<not_an_iterator, true>' requested here
    : __iterator_traits<_Iter, __has_iterator_category<_Iter>::value> {};
      ^
<source>:5:39: note: in instantiation of template class
'std::__1::iterator_traits<not_an_iterator>' requested here
std::iterator_traits<not_an_iterator> x;
                                      ^
In file included from <source>:1:
/opt/compiler-explorer/clang-trunk-20181110/bin/../include/c++/v1/iterator:457:29:
error: no type named 'value_type' in 'not_an_iterator'
    typedef typename _Iter::value_type        value_type;
            ~~~~~~~~~~~~~~~~^~~~~~~~~~
/opt/compiler-explorer/clang-trunk-20181110/bin/../include/c++/v1/iterator:458:29:
error: no type named 'pointer' in 'not_an_iterator'
    typedef typename _Iter::pointer           pointer;
            ~~~~~~~~~~~~~~~~^~~~~~~
/opt/compiler-explorer/clang-trunk-20181110/bin/../include/c++/v1/iterator:459:29:
error: no type named 'reference' in 'not_an_iterator'
    typedef typename _Iter::reference         reference;
            ~~~~~~~~~~~~~~~~^~~~~~~~~
4 errors generated.



The primary iterator_traits template merely tests for the presence of a nested
::iterator_concept typedef. It is required by the standard to test for the
presence of all the iterator typedefs: ::value_type, ::difference_type,
::reference, and ::pointer.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181110/3f60d098/attachment.html>


More information about the llvm-bugs mailing list