Update reference

This commit is contained in:
Peter Dimov
2021-09-16 03:07:32 +03:00
parent 3b70265ced
commit 39ad22d660
2 changed files with 77 additions and 12 deletions

View File

@ -1,16 +1,19 @@
//// ////
Copyright 2018-2021 Peter Dimov Copyright 2018-2021 Peter Dimov
Distributed under the Boost Software License, Version 1.0. Distributed under the Boost Software License, Version 1.0.
https://www.boost.org/LICENSE_1_0.txt
See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt
//// ////
[#changes] [#changes]
# Revision History # Revision History
:idprefix: :idprefix:
## Changes in Boost 1.78
* Added support for source locations to `error_code`.
* Added `error_code::to_string`.
* `system_error::what` now contains the source location, if present.
## Changes in Boost 1.77 ## Changes in Boost 1.77
* The conversion operator from `error_category` to `std::error_category` * The conversion operator from `error_category` to `std::error_category`

View File

@ -567,12 +567,18 @@ namespace boost {
template <class ErrorCodeEnum> template <class ErrorCodeEnum>
constexpr error_code( ErrorCodeEnum e ) noexcept; constexpr error_code( ErrorCodeEnum e ) noexcept;
error_code( int val, const error_category & cat,
boost::source_location const * loc ) noexcept;
error_code( std::error_code const& ec ) noexcept; error_code( std::error_code const& ec ) noexcept;
// modifiers: // modifiers:
constexpr void assign( int val, const error_category & cat ) noexcept; constexpr void assign( int val, const error_category & cat ) noexcept;
void assign( int val, const error_category & cat,
boost::source_location const * loc ) noexcept;
template<typename ErrorCodeEnum> template<typename ErrorCodeEnum>
constexpr error_code & operator=( ErrorCodeEnum e ) noexcept; constexpr error_code & operator=( ErrorCodeEnum e ) noexcept;
@ -591,6 +597,9 @@ namespace boost {
constexpr bool failed() const noexcept; constexpr bool failed() const noexcept;
constexpr explicit operator bool() const noexcept; constexpr explicit operator bool() const noexcept;
bool has_location() const noexcept;
boost::source_location const & location() const noexcept;
// comparisons: // comparisons:
friend constexpr bool operator==( const error_code & lhs, friend constexpr bool operator==( const error_code & lhs,
@ -638,6 +647,10 @@ namespace boost {
operator std::error_code(); operator std::error_code();
template<class T> operator T& (); // only when T=std::error_code template<class T> operator T& (); // only when T=std::error_code
// to_string
std::string to_string() const;
// stream insertion: // stream insertion:
template <class charT, class traits> template <class charT, class traits>
@ -661,7 +674,7 @@ constexpr error_code() noexcept;
[none] [none]
* {blank} * {blank}
+ +
Ensures: :: `value() == 0`; `category() == system_category()`. Ensures: :: `value() == 0`; `category() == system_category()`; `!has_location()`.
``` ```
constexpr error_code( int val, const error_category & cat ) noexcept; constexpr error_code( int val, const error_category & cat ) noexcept;
@ -669,7 +682,7 @@ constexpr error_code( int val, const error_category & cat ) noexcept;
[none] [none]
* {blank} * {blank}
+ +
Ensures: :: `value() == val`; `category() == cat`. Ensures: :: `value() == val`; `category() == cat`; `!has_location()`.
``` ```
template <class ErrorCodeEnum> template <class ErrorCodeEnum>
@ -681,6 +694,16 @@ template <class ErrorCodeEnum>
Ensures: :: `*this == make_error_code( e )`. Ensures: :: `*this == make_error_code( e )`.
Remarks: :: This constructor is only enabled when `is_error_code_enum<ErrorCodeEnum>::value` is `true`. Remarks: :: This constructor is only enabled when `is_error_code_enum<ErrorCodeEnum>::value` is `true`.
```
error_code( int val, const error_category & cat,
boost::source_location const * loc ) noexcept;
```
[none]
* {blank}
+
Requires: :: `loc` points to a valid `boost::source_location` object with static storage duration.
Ensures: :: `value() == val`; `category() == cat`; `has_location()`; `&location() == loc`.
``` ```
error_code( std::error_code const & ec ) noexcept; error_code( std::error_code const & ec ) noexcept;
``` ```
@ -688,7 +711,7 @@ error_code( std::error_code const & ec ) noexcept;
* {blank} * {blank}
+ +
Effects: :: Construct an `error_code` that wraps `ec`. Effects: :: Construct an `error_code` that wraps `ec`.
Remarks: :: `value()` and `category()` are unspecified. Remarks: :: `value()` and `category()` are unspecified. `has_location()` is `false`.
#### Modifiers #### Modifiers
@ -698,7 +721,17 @@ constexpr void assign( int val, const error_category & cat ) noexcept;
[none] [none]
* {blank} * {blank}
+ +
Ensures: :: `value() == val`; `category() == cat`. Ensures: :: `value() == val`; `category() == cat`; `!has_location()`.
```
void assign( int val, const error_category & cat,
boost::source_location const * loc ) noexcept;
```
[none]
* {blank}
+
Requires: :: `loc` points to a valid `boost::source_location` object with static storage duration.
Ensures: :: `value() == val`; `category() == cat`; `has_location()`; `&location() == loc`.
``` ```
template<typename ErrorCodeEnum> template<typename ErrorCodeEnum>
@ -782,6 +815,24 @@ constexpr explicit operator bool() const noexcept;
Returns: :: Returns: ::
`failed()`. `failed()`.
```
bool has_location() const noexcept;
```
[none]
* {blank}
+
Returns: :: `true` if `*this` has been constructed with a pointer to a source
location, `false` otherwise.
```
boost::source_location const & location() const noexcept;
```
[none]
* {blank}
+
Returns: :: `*loc` if `*this` has been constructed with a pointer to a source
location `loc`, a reference to a default-constructed `boost::source_location` otherwise.
#### Comparisons #### Comparisons
``` ```
@ -941,6 +992,19 @@ Effects: :: If `*this` wraps a `std::error_code` object `ec`,
Remarks: :: Remarks: ::
This operator is only enabled when `T` is `std::error_code`. This operator is only enabled when `T` is `std::error_code`.
#### to_string
```
std::string to_string() const;
```
[none]
* {blank}
+
Returns: :: If `*this` wraps a `std::error_code` object `e2`, a string that
is the concatenation of `"std:"`, `e2.category().name()`, `':'`, and the
string representation of `e2.value()`. Otherwise, the concatenation of
`category().name()`, `':'`, and the string representation of `value()`.
#### Stream Insertion #### Stream Insertion
``` ```
@ -951,10 +1015,8 @@ template <class charT, class traits>
[none] [none]
* {blank} * {blank}
+ +
Effects: :: If `ec` wraps a `std::error_code` object `e2`, `os << "std:" << e2`. Effects: :: `os << to_string()`.
Otherwise, `os << ec.category().name() << ':' << ec.value()`. Returns: :: `os`.
Returns: ::
`os`.
#### Nonmembers #### Nonmembers