optional_nullopt_t.fail.cpp 1.0 KB

123456789101112131415161718192021222324252627282930
  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. // UNSUPPORTED: c++98, c++03, c++11, c++14
  9. // <optional>
  10. // A program that necessitates the instantiation of template optional for
  11. // (possibly cv-qualified) nullopt_t is ill-formed.
  12. #include <optional>
  13. int main(int, char**)
  14. {
  15. using std::optional;
  16. using std::nullopt_t;
  17. using std::nullopt;
  18. optional<nullopt_t> opt; // expected-note 1 {{requested here}}
  19. optional<const nullopt_t> opt1; // expected-note 1 {{requested here}}
  20. optional<nullopt_t &> opt2; // expected-note 1 {{requested here}}
  21. optional<nullopt_t &&> opt3; // expected-note 1 {{requested here}}
  22. // expected-error@optional:* 4 {{instantiation of optional with nullopt_t is ill-formed}}
  23. return 0;
  24. }