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 9 // <system_error> 10 11 // class error_code 12 13 // template <ErrorCodeEnum E> error_code& operator=(E e); 14 15 #include <system_error> 16 #include <cassert> 17 18 #include "test_macros.h" 19 20 enum testing 21 { 22 zero, one, two 23 }; 24 25 namespace std 26 { 27 28 template <> struct is_error_code_enum<testing> : public std::true_type {}; 29 30 } 31 32 std::error_code make_error_code(testing x)33make_error_code(testing x) 34 { 35 return std::error_code(static_cast<int>(x), std::generic_category()); 36 } 37 main(int,char **)38int main(int, char**) 39 { 40 { 41 std::error_code ec; 42 ec = two; 43 assert(ec.value() == 2); 44 assert(ec.category() == std::generic_category()); 45 } 46 47 return 0; 48 } 49