mirror of
https://git.suyu.dev/suyu/suyu
synced 2026-07-02 04:19:04 +00:00
28 lines
1.0 KiB
Plaintext
Executable File
28 lines
1.0 KiB
Plaintext
Executable File
////
|
|
Copyright 2003-2017 Beman Dawes
|
|
|
|
Distributed under the Boost Software License, Version 1.0.
|
|
|
|
See accompanying file LICENSE_1_0.txt or copy at
|
|
http://www.boost.org/LICENSE_1_0.txt
|
|
////
|
|
|
|
[#rationale]
|
|
# Design Rationale
|
|
:idprefix: rationale_
|
|
|
|
`error_code` and `error_condition` are designed as value types so
|
|
they can be copied without slicing and do not require heap allocation, but
|
|
still have polymorphic behavior based on the error category. This is achieved
|
|
by abstract base class `error_category` supplying the polymorphic behavior,
|
|
and `error_code` and `error_condition` containing a pointer to an object of a
|
|
type derived from `error_category`.
|
|
|
|
Many of the detailed design decisions were driven by the requirements that
|
|
users to be able to add additional error categories, and that it be no more
|
|
difficult to write portable code than system-specific code.
|
|
|
|
The `operator<<` overload for `error_code` eliminates a misleading conversion to
|
|
`bool` in code like `cout << ec`, where `ec` is of type `error_code`. It is also
|
|
useful in its own right.
|