1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // UNSUPPORTED: c++03, c++11, c++14, c++17 10 11 // This test checks that std::contiguous_iterator uses std::to_address, which is not SFINAE-friendly 12 // when the type is missing the `T::element_type` typedef. 13 14 #include <iterator> 15 16 #include <compare> 17 #include <cstddef> 18 19 struct no_element_type { 20 typedef std::contiguous_iterator_tag iterator_category; 21 typedef int value_type; 22 typedef std::ptrdiff_t difference_type; 23 typedef int* pointer; 24 typedef int& reference; 25 typedef no_element_type self; 26 27 no_element_type(); 28 29 reference operator*() const; 30 pointer operator->() const; 31 auto operator<=>(const self&) const = default; 32 33 self& operator++(); 34 self operator++(int); 35 36 self& operator--(); 37 self operator--(int); 38 39 self& operator+=(difference_type n); 40 self operator+(difference_type n) const; 41 friend self operator+(difference_type n, self x); 42 43 self& operator-=(difference_type n); 44 self operator-(difference_type n) const; 45 difference_type operator-(const self& n) const; 46 47 reference operator[](difference_type n) const; 48 }; 49 test()50void test() { 51 (void) std::contiguous_iterator<no_element_type>; 52 // expected-error@*:* {{implicit instantiation of undefined template}} 53 // expected-note@*:* {{to_address}} 54 } 55