42 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8// UNSUPPORTED: c++03, c++11, c++14, c++179 10// <system_error>11 12// class error_code13 14// strong_ordering operator<=>(const error_code& lhs, const error_code& rhs) noexcept15 16#include <system_error>17#include <cassert>18 19#include "test_macros.h"20#include "test_comparisons.h"21 22int main(int, char**) {23 AssertOrderAreNoexcept<std::error_code>();24 AssertOrderReturn<std::strong_ordering, std::error_code>();25 26 // Same error category27 std::error_code ec1a = std::error_code(1, std::generic_category());28 std::error_code ec1b = std::error_code(1, std::generic_category());29 std::error_code ec2 = std::error_code(2, std::generic_category());30 31 assert(testOrder(ec1a, ec1b, std::strong_ordering::equal));32 assert(testOrder(ec1a, ec2, std::strong_ordering::less));33 34 // Different error category35 const std::error_code& ec3 = std::error_code(2, std::system_category());36 37 bool isLess = ec2 < ec3;38 assert(testOrder(ec2, ec3, isLess ? std::strong_ordering::less : std::strong_ordering::greater));39 40 return 0;41}42