string_view_deduction.fail.cpp (1286B)
1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <string> 11 // UNSUPPORTED: c++98, c++03, c++11, c++14 12 // XFAIL: libcpp-no-deduction-guides 13 14 // template<class InputIterator> 15 // basic_string(InputIterator begin, InputIterator end, 16 // const Allocator& a = Allocator()); 17 18 // template<class charT, 19 // class traits, 20 // class Allocator = allocator<charT> 21 // > 22 // basic_string(basic_string_view<charT, traits>, const Allocator& = Allocator()) 23 // -> basic_string<charT, traits, Allocator>; 24 // 25 // The deduction guide shall not participate in overload resolution if Allocator 26 // is a type that does not qualify as an allocator. 27 28 29 #include <string> 30 #include <string_view> 31 #include <iterator> 32 #include <cassert> 33 #include <cstddef> 34 35 int main() 36 { 37 { 38 std::string_view sv = "12345678901234"; 39 std::basic_string s1{sv, 23}; // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'basic_string'}} 40 } 41 }