alloc_convert_copy.fail.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. // <tuple>
  9. // template <class... Types> class tuple;
  10. // template <class Alloc, class ...UTypes>
  11. // tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...> const&);
  12. // UNSUPPORTED: c++98, c++03
  13. #include <tuple>
  14. #include <memory>
  15. struct ExplicitCopy {
  16. explicit ExplicitCopy(int) {}
  17. explicit ExplicitCopy(ExplicitCopy const&) {}
  18. };
  19. std::tuple<ExplicitCopy> const_explicit_copy_test() {
  20. const std::tuple<int> t1(42);
  21. return {std::allocator_arg, std::allocator<void>{}, t1};
  22. // expected-error@-1 {{chosen constructor is explicit in copy-initialization}}
  23. }
  24. std::tuple<ExplicitCopy> non_const_explicit_copy_test() {
  25. std::tuple<int> t1(42);
  26. return {std::allocator_arg, std::allocator<void>{}, t1};
  27. // expected-error@-1 {{chosen constructor is explicit in copy-initialization}}
  28. }
  29. int main(int, char**)
  30. {
  31. return 0;
  32. }