Home | History | Annotate | Download | only in syserr.errcat.nonvirtuals
      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 // <system_error>
     11 
     12 // class error_category
     13 
     14 // constexpr error_category() noexcept;
     15 
     16 #include <system_error>
     17 #include <type_traits>
     18 #include <string>
     19 #include <cassert>
     20 
     21 #if _LIBCPP_STD_VER > 11
     22 
     23 class test1
     24     : public std::error_category
     25 {
     26 public:
     27     constexpr test1() = default;  // won't compile if error_category() is not constexpr
     28     virtual const char* name() const noexcept {return nullptr;}
     29     virtual std::string message(int ev) const {return std::string();}
     30 };
     31 
     32 #endif  // _LIBCPP_STD_VER > 11
     33 
     34 int main()
     35 {
     36 #if _LIBCPP_STD_VER > 11
     37     static_assert(std::is_nothrow_default_constructible<test1>::value,
     38                                  "error_category() must exist and be noexcept");
     39 #endif  // _LIBCPP_STD_VER > 11
     40 }
     41