string_view_deduction.fail.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. // <string>
  9. // UNSUPPORTED: c++98, c++03, c++11, c++14
  10. // XFAIL: libcpp-no-deduction-guides
  11. // template<class InputIterator>
  12. // basic_string(InputIterator begin, InputIterator end,
  13. // const Allocator& a = Allocator());
  14. // template<class charT,
  15. // class traits,
  16. // class Allocator = allocator<charT>
  17. // >
  18. // basic_string(basic_string_view<charT, traits>, const Allocator& = Allocator())
  19. // -> basic_string<charT, traits, Allocator>;
  20. //
  21. // The deduction guide shall not participate in overload resolution if Allocator
  22. // is a type that does not qualify as an allocator.
  23. #include <string>
  24. #include <string_view>
  25. #include <iterator>
  26. #include <cassert>
  27. #include <cstddef>
  28. int main(int, char**)
  29. {
  30. {
  31. std::string_view sv = "12345678901234";
  32. std::basic_string s1{sv, 23}; // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'basic_string'}}
  33. }
  34. return 0;
  35. }