Apache C++ Standard Library User's Guide

## 46.1 Extensions

This section describes how this implementation of the standard iostreams differs from the ISO/ANSI C++ Standard Library specification. You must be aware that whenever you use one of the features described here, the portability of your program is impaired. It will not conform to the standard.

### 46.1.1 File Descriptors

The traditional iostreams allowed a file stream to connect to a file using a file descriptor. File descriptors are used by POSIX functions like `open()`, `close()`, `read()`, and `write()`. However, the ISO/ANSI standard for the programming language C and its library does not include these functions, nor does it mention file descriptors. In this sense, the use of file descriptors introduces platform and operating system dependencies into your program. This is exactly why the standard iostreams are not defined to use file descriptors.

You may have existing programs that use the file descriptor features of the traditional iostreams. You may need to access system-specific files like pipes, which are accessible only through file descriptors. To address these concerns, this implementation offers additional constructors and member functions in the file stream and file buffer classes that enable you to work with file descriptors.

The main additions are:

- Constructors that take a file descriptor rather than a file name

- An additional third parameter that allows specification of file access rights. This parameter, available on several constructors and the `open()` member functions, is not available with the standard interface. The parameter has a default, so that you usually need not worry about file protection.

### 46.1.2 Multithreaded Environments

See Chapter 44 on multithreading. Note that all multithreading features are an extension of the standard and are therefore not portable to other implementations of the standard library.