deduct.fail.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. // <queue>
  9. // UNSUPPORTED: c++98, c++03, c++11, c++14
  10. // UNSUPPORTED: libcpp-no-deduction-guides
  11. #include <queue>
  12. #include <list>
  13. #include <iterator>
  14. #include <cassert>
  15. #include <cstddef>
  16. int main(int, char**)
  17. {
  18. // Test the explicit deduction guides
  19. {
  20. // queue(const Container&, const Alloc&);
  21. // The '45' is not an allocator
  22. std::queue que(std::list<int>{1,2,3}, 45); // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'queue'}}
  23. }
  24. {
  25. // queue(const queue&, const Alloc&);
  26. // The '45' is not an allocator
  27. std::queue<int> source;
  28. std::queue que(source, 45); // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'queue'}}
  29. }
  30. // Test the implicit deduction guides
  31. {
  32. // queue (allocator &)
  33. std::queue que((std::allocator<int>())); // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'queue'}}
  34. // Note: The extra parens are necessary, since otherwise clang decides it is a function declaration.
  35. // Also, we can't use {} instead of parens, because that constructs a
  36. // stack<allocator<int>, allocator<allocator<int>>>
  37. }
  38. return 0;
  39. }