Blame libs/system/doc/index.html

Packit 58578d
<html>
Packit 58578d
Packit 58578d
<head>
Packit 58578d
<meta http-equiv="Content-Language" content="en-us">
Packit 58578d
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
Packit 58578d
<meta name="ProgId" content="FrontPage.Editor.Document">
Packit 58578d
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
Packit 58578d
<title>Boost System Library</title>
Packit 58578d
<link rel="stylesheet" type="text/css" href="../../../doc/src/minimal.css">
Packit 58578d
</head>
Packit 58578d
Packit 58578d
<body>
Packit 58578d
Packit 58578d
Packit 58578d
  
Packit 58578d
    
Packit 58578d
Packit 58578d
boost.png (6897 bytes)
Packit 58578d
    
Packit 58578d
    <font size="7">System Library</font>
Packit 58578d
    
Packit 58578d
  
Packit 58578d
Packit 58578d
Packit 58578d
Packit 58578d
  
Packit 58578d
    Boost Home    
Packit 58578d
    Library Home   Tutorial   
Packit 58578d
    Reference
Packit 58578d
  
Packit 58578d
Packit 58578d
Packit 58578d
Packit 58578d
  
Packit 58578d
    
Packit 58578d
      Contents
Packit 58578d
  
Packit 58578d
  
Packit 58578d
    
Packit 58578d
      Introduction
Packit 58578d
      Release History
Packit 58578d
      Design Rationale
Packit 58578d
      History
Packit 58578d
      Acknowledgements
Packit 58578d
    
Packit 58578d
  
Packit 58578d
  
Packit 58578d
    
Packit 58578d
      Headers
Packit 58578d
  
Packit 58578d
  
Packit 58578d
    
Packit 58578d
      <boost/system/error_code.hpp>
Packit 58578d
      
Packit 58578d
      <boost/system/system_error.hpp>
Packit 58578d
      
Packit 58578d
      <boost/system/cygwin_error.hpp>
Packit 58578d
      
Packit 58578d
      <boost/system/linux_error.hpp>
Packit 58578d
      
Packit 58578d
      <boost/system/windows_error.hpp>
Packit 58578d
  
Packit 58578d
Packit 58578d
Packit 58578d

Introduction

Packit 58578d
Packit 58578d

Error conditions originating from the operating system or other low-level

Packit 58578d
application program interfaces (API's) are typically reported via an integer 
Packit 58578d
representing an error code. When these low-level API calls are wrapped in 
Packit 58578d
portable code, such as in a portable library, some users want to deal with the 
Packit 58578d
error codes in portable ways. Other users need to get at the system specific 
Packit 58578d
error codes, so they can deal with system specific needs. The Boost System 
Packit 58578d
library provides simple, light-weight 
Packit 58578d
error_code objects that encapsulate system-specific error code values, yet 
Packit 58578d
also provide access to more abstract and portable error conditions via
Packit 58578d
error_condition objects. 
Packit 58578d
Because error_code objects can represent errors from sources other than the 
Packit 58578d
operating system, including user-defined sources, each error_code and 
Packit 58578d
error_condition has an associated 
Packit 58578d
error_category.

Packit 58578d
Packit 58578d

An exception class, 

Packit 58578d
system_error, is provided. Derived from std::runtime_error, it captures the 
Packit 58578d
underlying error_code for the problem causing the exception so that this 
Packit 58578d
important information is not lost.

Packit 58578d

While exceptions are the preferred C++ default error code reporting

Packit 58578d
mechanism, users of libraries dependent on low-level API's often need overloads 
Packit 58578d
reporting error conditions via error code arguments and/or return values rather 
Packit 58578d
than via throwing exceptions. Otherwise, when errors are not exceptional 
Packit 58578d
occurrences and must be dealt with as they arise, programs become littered with 
Packit 58578d
try/catch blocks, unreadable, and very inefficient. The Boost System library 
Packit 58578d
supports both error reporting by exception and by error code.

Packit 58578d

In addition to portable errors codes and conditions supported by the

Packit 58578d
error_code.hpp header, system-specific headers support the Cygwin, Linux, 
Packit 58578d
and Windows platforms. These headers are effectively no-ops if included for 
Packit 58578d
platforms other than their intended target.

Packit 58578d
Packit 58578d
  
Packit 58578d
    The Boost System Library is part of the C++11 Standard Library. 
Packit 58578d
    A number of changes, particularly to names, were made by the C++ committee 
Packit 58578d
    during standardization. The Boost implementation is tracking those changes. 
Packit 58578d
    See Deprecated names for 
Packit 58578d
    synonyms provided to prevent breakage of existing user code. See
Packit 58578d
    Breaking changes for changes 
Packit 58578d
    that unavoidably break existing user code. All breaking changes are noisy 
Packit 58578d
    and will cause compile-time errors.
Packit 58578d
  
Packit 58578d
Packit 58578d

Release History

Packit 58578d

system-2014-06-02: First modular Boost release. Minor

Packit 58578d
maintenance changes.

Packit 58578d

Design Rationale

Packit 58578d

Class error_code  and error_condition are designed as a value types so

Packit 58578d
they can be copied 
Packit 58578d
without slicing and do not requiring heap allocation, but still have polymorphic 
Packit 58578d
behavior based on the error category. This is achieved by abstract base class
Packit 58578d
error_category supplying the polymorphic behavior, and 
Packit 58578d
error_code and error_condition containing a pointer to an object of a type derived from 
Packit 58578d
error_category.

Packit 58578d

Many of the detailed design decisions were driven by the requirements that

Packit 58578d
users to be able to add additional error categories, and that it be no more 
Packit 58578d
difficult to write portable code than system-specific code.

Packit 58578d

The operator<< overload for error_code eliminates a

Packit 58578d
misleading conversion to bool in code like cout << ec, where 
Packit 58578d
ec is of type error_code. It is also useful in its own 
Packit 58578d
right.

Packit 58578d

History

Packit 58578d

Packit 58578d
N1975, Filesystem Library Proposal for TR2, accepted for Library Technical 
Packit 58578d
Report 2 (TR2) at the Berlin meeting, included additional components to 
Packit 58578d
supplement the Standard Library's Diagnostics clause. Since then, these error 
Packit 58578d
reporting components have received wider public scrutiny and enhancements have 
Packit 58578d
been made to the design. The enhanced version has been used by N2054, Networking 
Packit 58578d
Library Proposal for TR2, demonstrating that these error reporting components 
Packit 58578d
are useful beyond the original Filesystem Library.

Packit 58578d

The original proposal viewed error categories as a binary choice between

Packit 58578d
errno (i.e. POSIX-style) and the native operating system's error 
Packit 58578d
codes. The proposed components now allow as many additional error categories as 
Packit 58578d
are needed by either implementations or by users. The need to support additional 
Packit 58578d
error categories, for example, occurs in some networking library implementations 
Packit 58578d
because they are built on top of the POSIX getaddrinfo API that 
Packit 58578d
uses error codes not based on errno.

Packit 58578d

Acknowledgements

Packit 58578d

Christopher Kohlhoff and Peter Dimov made important contributions to the

Packit 58578d
design. Comments and suggestions were also received from Pavel Vozenilek, 
Packit 58578d
Gennaro Prota, Dave Abrahams, Jeff Garland, Iain Hanson, Oliver Kowalke, and 
Packit 58578d
Oleg Abrosimov. Christopher Kohlhoff suggested several improvements to the N2066 
Packit 58578d
paper. Johan Nilsson's comments led to several of the refinements in N2066 .

Packit 58578d

Packit 58578d
Packit 58578d

Revised

Packit 58578d
June 02, 2014 </font>
Packit 58578d

Packit 58578d
Packit 58578d

© Copyright Beman Dawes, 1999

Packit 58578d
Packit 58578d

Distributed under the Boost Software License, Version 1.0.

Packit 58578d
(See file LICENSE_1_0.txt
Packit 58578d
or  www.boost.org/LICENSE_1_0.txt) 

Packit 58578d
Packit 58578d
</body>
Packit 58578d
Packit 58578d
</html>