1//// 2Copyright 2003-2017 Beman Dawes 3 4Distributed under the Boost Software License, Version 1.0. 5 6See accompanying file LICENSE_1_0.txt or copy at 7http://www.boost.org/LICENSE_1_0.txt 8//// 9 10[#rationale] 11# Design Rationale 12:idprefix: rationale_ 13 14`error_code` and `error_condition` are designed as value types so 15they can be copied without slicing and do not require heap allocation, but 16still have polymorphic behavior based on the error category. This is achieved 17by abstract base class `error_category` supplying the polymorphic behavior, 18and `error_code` and `error_condition` containing a pointer to an object of a 19type derived from `error_category`. 20 21Many of the detailed design decisions were driven by the requirements that 22users to be able to add additional error categories, and that it be no more 23difficult to write portable code than system-specific code. 24 25The `operator<<` overload for `error_code` eliminates a misleading conversion to 26`bool` in code like `cout << ec`, where `ec` is of type `error_code`. It is also 27useful in its own right. 28