mirror of
https://github.com/boostorg/utility.git
synced 2025-11-02 17:32:46 +01:00
Compare commits
21 Commits
boost-1.78
...
boost-1.79
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69f6588d7c | ||
|
|
6950023bca | ||
|
|
c3aab6a184 | ||
|
|
7717dac7bc | ||
|
|
63aadf3f0f | ||
|
|
0feb28b467 | ||
|
|
78f1b38930 | ||
|
|
e6edd4eb91 | ||
|
|
9d1284ef6d | ||
|
|
aa0ccfa65e | ||
|
|
c21d2818c7 | ||
|
|
5ae025b56a | ||
|
|
f3f7c3c041 | ||
|
|
bdc983b804 | ||
|
|
a1583e3072 | ||
|
|
30caa722c1 | ||
|
|
96169c9fc6 | ||
|
|
b6119df27f | ||
|
|
9941e831bb | ||
|
|
a8cdbe516d | ||
|
|
485a160dde |
@@ -35,7 +35,7 @@ In addition, LL and ULL suffixes may be used for representing
|
||||
them as an extension.
|
||||
|
||||
The `BOOST_BINARY` family of macros resides in the header
|
||||
[@../../../include/boost/utility/binary.hpp <boost/utility/binary.hpp>].
|
||||
[@../../../../boost/utility/binary.hpp <boost/utility/binary.hpp>].
|
||||
|
||||
[endsect]
|
||||
|
||||
@@ -79,7 +79,3 @@ Contributed by Matt Calabrese.
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,50 +2,19 @@
|
||||
# subject to 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)
|
||||
|
||||
import project ;
|
||||
import doxygen ;
|
||||
import quickbook ;
|
||||
|
||||
project : requirements
|
||||
# Path for links to Boost:
|
||||
<xsl:param>boost.root=../../../..
|
||||
|
||||
# Some general style settings:
|
||||
<xsl:param>table.footnote.number.format=1
|
||||
<xsl:param>footnote.number.format=1
|
||||
|
||||
# HTML options first:
|
||||
# Use graphics not text for navigation:
|
||||
<xsl:param>navig.graphics=1
|
||||
# PDF Options:
|
||||
# TOC Generation: this is needed for FOP-0.9 and later:
|
||||
<xsl:param>fop1.extensions=0
|
||||
<xsl:param>xep.extensions=1
|
||||
# TOC generation: this is needed for FOP 0.2, but must not be set to zero for FOP-0.9!
|
||||
<xsl:param>fop.extensions=0
|
||||
# No indent on body text:
|
||||
<xsl:param>body.start.indent=0pt
|
||||
# Margin size:
|
||||
<xsl:param>page.margin.inner=0.5in
|
||||
# Margin size:
|
||||
<xsl:param>page.margin.outer=0.5in
|
||||
# Paper type = A4
|
||||
<xsl:param>paper.type=A4
|
||||
# Yes, we want graphics for admonishments:
|
||||
<xsl:param>admon.graphics=1
|
||||
# Set this one for PDF generation *only*:
|
||||
# default pnd graphics are awful in PDF form,
|
||||
# better use SVG's instead:
|
||||
<format>pdf:<xsl:param>admon.graphics.extension=".svg"
|
||||
<format>pdf:<xsl:param>"admon.graphics.path=$(boost-images)/"
|
||||
<format>pdf:<xsl:param>"boost.url.prefix=http://www.boost.org/doc/libs/release/libs/utility/doc/html"
|
||||
;
|
||||
project boost/libs/utility/doc ;
|
||||
|
||||
path-constant INCLUDES : ../../.. ;
|
||||
path-constant boost-images : ../../../doc/src/images ;
|
||||
|
||||
# Generate XML doxygen reference for base_from_member component in base_from_member_reference.xml
|
||||
doxygen base_from_member_reference
|
||||
:
|
||||
../include/boost/utility/base_from_member.hpp
|
||||
$(INCLUDES)/boost/utility/base_from_member.hpp
|
||||
:
|
||||
<location>tmp
|
||||
<doxygen:param>ENABLE_PREPROCESSING=YES
|
||||
@@ -89,7 +58,7 @@ doxygen base_from_member_reference
|
||||
# Generate XML doxygen reference for boost_binary component in boost_binary_reference.xml
|
||||
doxygen boost_binary_reference
|
||||
:
|
||||
../include/boost/utility/binary.hpp
|
||||
$(INCLUDES)/boost/utility/binary.hpp
|
||||
:
|
||||
<location>tmp
|
||||
<doxygen:param>ENABLE_PREPROCESSING=YES
|
||||
@@ -133,8 +102,8 @@ doxygen boost_binary_reference
|
||||
# Generate XML doxygen reference for call_traits component in call_traits_reference.xml
|
||||
doxygen call_traits_reference
|
||||
:
|
||||
../include/boost/call_traits.hpp
|
||||
../include/boost/detail/call_traits.hpp
|
||||
$(INCLUDES)/boost/call_traits.hpp
|
||||
$(INCLUDES)/boost/detail/call_traits.hpp
|
||||
:
|
||||
<location>tmp
|
||||
<doxygen:param>ENABLE_PREPROCESSING=YES
|
||||
@@ -178,8 +147,8 @@ doxygen call_traits_reference
|
||||
# Generate XML doxygen reference for compressed_pair component in compressed_pair_reference.xml
|
||||
doxygen compressed_pair_reference
|
||||
:
|
||||
../include/boost/compressed_pair.hpp
|
||||
../include/boost/detail/compressed_pair.hpp
|
||||
$(INCLUDES)/boost/compressed_pair.hpp
|
||||
$(INCLUDES)/boost/detail/compressed_pair.hpp
|
||||
:
|
||||
<location>tmp
|
||||
<doxygen:param>ENABLE_PREPROCESSING=YES
|
||||
@@ -223,8 +192,8 @@ doxygen compressed_pair_reference
|
||||
# Generate XML doxygen reference for in_place_factory component in in_place_factory_reference.xml
|
||||
doxygen in_place_factory_reference
|
||||
:
|
||||
../include/boost/utility/in_place_factory.hpp
|
||||
../include/boost/utility/typed_in_place_factory.hpp
|
||||
$(INCLUDES)/boost/utility/in_place_factory.hpp
|
||||
$(INCLUDES)/boost/utility/typed_in_place_factory.hpp
|
||||
:
|
||||
<location>tmp
|
||||
<doxygen:param>ENABLE_PREPROCESSING=YES
|
||||
@@ -271,7 +240,7 @@ doxygen in_place_factory_reference
|
||||
# Generate XML doxygen reference for result_of component in result_of_reference.xml
|
||||
doxygen result_of_reference
|
||||
:
|
||||
../include/boost/utility/result_of.hpp
|
||||
$(INCLUDES)/boost/utility/result_of.hpp
|
||||
:
|
||||
<location>tmp
|
||||
<doxygen:param>ENABLE_PREPROCESSING=YES
|
||||
@@ -315,7 +284,7 @@ doxygen result_of_reference
|
||||
# Generate XML doxygen reference for string_view component in string_view_reference.xml
|
||||
doxygen string_view_reference
|
||||
:
|
||||
../include/boost/utility/string_view.hpp
|
||||
$(INCLUDES)/boost/utility/string_view.hpp
|
||||
:
|
||||
<location>tmp
|
||||
<doxygen:param>ENABLE_PREPROCESSING=YES
|
||||
@@ -359,7 +328,7 @@ doxygen string_view_reference
|
||||
# Generate XML doxygen reference for value_init component in value_init_reference.xml
|
||||
doxygen value_init_reference
|
||||
:
|
||||
../include/boost/utility/value_init.hpp
|
||||
$(INCLUDES)/boost/utility/value_init.hpp
|
||||
:
|
||||
<location>tmp
|
||||
<doxygen:param>ENABLE_PREPROCESSING=YES
|
||||
@@ -440,6 +409,5 @@ boostbook standalone_main
|
||||
alias boostdoc ;
|
||||
explicit boostdoc ;
|
||||
|
||||
alias boostrelease :
|
||||
standalone_main ;
|
||||
alias boostrelease : standalone_main ;
|
||||
explicit boostrelease ;
|
||||
|
||||
@@ -112,7 +112,7 @@ type does not need to concern itself with the integer.
|
||||
#endif
|
||||
|
||||
template < typename MemberType, int UniqueID = 0 >
|
||||
class __boost_base_from_member__
|
||||
class __base_from_member__
|
||||
{
|
||||
protected:
|
||||
MemberType member;
|
||||
@@ -192,7 +192,6 @@ maintain the same maximum size. (Example code would be a class that uses
|
||||
this class template as a base class for a member with a flexible set of
|
||||
constructors.) This constant is ignored when C++11 features are present.
|
||||
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Basic Usage]
|
||||
@@ -237,7 +236,6 @@ safe to use in the latter sub-object's construction. Since the `fdoutbuf`
|
||||
sub-object of the final type is the only sub-object with the name `member`
|
||||
that name can be used unqualified within the final class.
|
||||
|
||||
|
||||
[endsect]
|
||||
|
||||
[section Multiple Sub-Objects]
|
||||
@@ -322,8 +320,8 @@ type. Using `typedef`s ease mentioning the base types.
|
||||
|
||||
However, the fix introduces a new problem when a pointer is needed. Using the
|
||||
address operator with a sub-object qualified with its class's name results in a
|
||||
pointer-to-member (here, having a type of `an_int __boost_base_from_member__<an_int, 0>:: *`)
|
||||
instead of a pointer to the member (having a type of `an_int *`).
|
||||
pointer-to-member (here, having a type of `an_int __boost_base_from_member__<an_int, 0>::*`)
|
||||
instead of a pointer to the member (having a type of `an_int*`).
|
||||
The new problem is fixed by qualifying the sub-object with `this->` and is needed
|
||||
just for pointers, and not for references or values.
|
||||
|
||||
@@ -338,9 +336,9 @@ C++ always interprets such code as an integer when it has overloads that can
|
||||
take either an integer or a pointer.
|
||||
|
||||
The last conversion is necessary for the compiler to call a constructor form
|
||||
with the exact pointer type used in `switcher`'s constructor. (If C++11's
|
||||
__nullptr__ is used, it still needs a conversion if multiple pointer types can
|
||||
be accepted in a constructor call but `__std_nullptr_t__` cannot.)
|
||||
with the exact pointer type used in `switcher`'s constructor. (If C++11's
|
||||
__nullptr__ is used, it still needs a conversion if multiple pointer types can
|
||||
be accepted in a constructor call but `__std_nullptr_t__` cannot.)
|
||||
|
||||
[endsect]
|
||||
|
||||
@@ -355,25 +353,24 @@ Author: Walker, Daryle
|
||||
Copyright 2001, 2003, 2004, 2012 Daryle Walker
|
||||
|
||||
* [@http://www.boost.org/people/ed_brey.htm Ed Brey] suggested some interface
|
||||
changes.
|
||||
changes.
|
||||
|
||||
* [@http://www.moocat.org R. Samuel Klatchko] ([@mailto:rsk@moocat.org
|
||||
rsk@moocat.org], [@mailto:rsk@brightmail.com rsk@brightmail.com]) invented
|
||||
the idiom of how to use a class member for initializing a base class.
|
||||
rsk@moocat.org], [@mailto:rsk@brightmail.com rsk@brightmail.com]) invented
|
||||
the idiom of how to use a class member for initializing a base class.
|
||||
|
||||
* [@http://www.boost.org/people/dietmar_kuehl.htm Dietmar Kuehl] popularized the
|
||||
base-from-member idiom in his [@http://www.informatik.uni-konstanz.de/~kuehl/c++/iostream/
|
||||
base-from-member idiom in his [@http://www.informatik.uni-konstanz.de/~kuehl/c++/iostream/
|
||||
IOStream example classes].
|
||||
|
||||
* Jonathan Turkanis supplied an implementation of generating the constructor
|
||||
templates that can be controlled and automated with macros. The
|
||||
implementation uses the [@boost:/doc/html/preprocessor/index.html Preprocessor library].
|
||||
templates that can be controlled and automated with macros. The
|
||||
implementation uses the [@boost:/libs/preprocessor/index.html Preprocessor library].
|
||||
|
||||
* [@http://www.boost.org/people/daryle_walker.html">Daryle Walker] started the
|
||||
library. Contributed the test file [@../../../test/base_from_member_test.cpp
|
||||
base_from_member_test.cpp].
|
||||
library. Contributed the test file [@../../../test/base_from_member_test.cpp
|
||||
base_from_member_test.cpp].
|
||||
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
[section Introduction]
|
||||
|
||||
All of the contents of [@../../../include/boost/call_traits.hpp `<boost/call_traits.hpp>`] are
|
||||
All of the contents of [@../../../../boost/call_traits.hpp `<boost/call_traits.hpp>`] are
|
||||
defined inside `namespace boost`.
|
||||
|
||||
The template class __call_traits_T__ encapsulates the
|
||||
@@ -159,7 +159,7 @@ various types.
|
||||
[[From `int&`] [`int&`] [`int&`] [`const int&`] [`int&`] [All reference types]]
|
||||
[[From `const int&`] [`const int&`] [`const int&`] [`const int&`] [`const int&`] [All constant reference types]]
|
||||
[[From `int[3]`] [`const int*`] [`int(&)[3]`] [`const int(&)[3]`] [`const int* const`] [All array types]]
|
||||
[[From `const int[3]`] [`const int*`] [`const int(&)[3]`] [`const int(&)[3]`] [`const int *const`] [All constant array types]]
|
||||
[[From `const int[3]`] [`const int*`] [`const int(&)[3]`] [`const int(&)[3]`] [`const int* const`] [All constant array types]]
|
||||
]
|
||||
|
||||
The table assumes the compiler supports partial
|
||||
@@ -284,7 +284,7 @@ The __call_traits__ template will "optimize" the passing
|
||||
of a small built-in type as a function parameter. This mainly has
|
||||
an effect when the parameter is used within a loop body.
|
||||
|
||||
In the following example (see [@boost:/doc/html/type_traits/examples/fill_example.cpp `fill_example.cpp`]),
|
||||
In the following example (see [@boost:/libs/type_traits/examples/fill_example.cpp `fill_example.cpp`]),
|
||||
a version of __std_fill__ is optimized in two ways: if the type
|
||||
passed is a single byte built-in type then __std_memset__ is used to
|
||||
effect the fill, otherwise a conventional C++ implementation is
|
||||
@@ -441,8 +441,3 @@ specialisation.
|
||||
[/===============]
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
[section Introduction]
|
||||
|
||||
All of the contents of [@../../../include/boost/compressed_pair.hpp `<boost/compressed_pair.hpp>`] are defined inside
|
||||
All of the contents of [@../../../../boost/compressed_pair.hpp `<boost/compressed_pair.hpp>`] are defined inside
|
||||
`namespace boost`.
|
||||
|
||||
The class __compressed_pair__ is very similar to __std_pair__. However, if either of
|
||||
@@ -71,8 +71,8 @@ a default value.
|
||||
|
||||
Note that __compressed_pair__ can not be instantiated if either of the
|
||||
template arguments is a union type, unless there is compiler support for
|
||||
[@boost:/doc/html/type_traits/index.html `boost::is_union`], or
|
||||
if [@boost:/doc/html/type_traits/index.html `boost::is_union`] is
|
||||
[@boost:/libs/type_traits/index.html `boost::is_union`], or
|
||||
if [@boost:/libs/type_traits/index.html `boost::is_union`] is
|
||||
specialised for the union type.
|
||||
|
||||
Finally, a word of caution for Visual C++ 6 users: if either argument is an
|
||||
|
||||
@@ -18,7 +18,7 @@ Suppose we have a class
|
||||
```
|
||||
struct X
|
||||
{
|
||||
X ( int, _std__string_ ) ;
|
||||
X ( int, __std_string__ ) ;
|
||||
};
|
||||
```
|
||||
|
||||
@@ -70,7 +70,7 @@ struct C
|
||||
{
|
||||
C() : contained_(0) {}
|
||||
C ( X const& v ) : contained_ ( new X(v) ) {}
|
||||
C ( int a0, std::string a1 ) : contained_ ( new X(a0,a1) ) {}
|
||||
C ( int a0, __std_string__ a1 ) : contained_ ( new X(a0,a1) ) {}
|
||||
~C() { delete contained_ ; }
|
||||
X* contained_ ;
|
||||
};
|
||||
@@ -100,8 +100,8 @@ correctly aligned and sized. Naturally, the container will typically support uni
|
||||
in-place construction to override a fully-constructed object, as this would defeat the purpose of in-place construction.
|
||||
|
||||
For this purpose, the framework provides two concepts called: InPlaceFactories and TypedInPlaceFactories.
|
||||
Helpers to declare these classes are declared in [@../../../include/boost/utility/in_place_factory.hpp `<boost/utility/in_place_factory.hpp>`]
|
||||
and [@../../../include/boost/utility/typed_in_place_factory.hpp `<boost/utility/typed_in_place_factory.hpp>`].
|
||||
Helpers to declare these classes are declared in [@../../../../boost/utility/in_place_factory.hpp `<boost/utility/in_place_factory.hpp>`]
|
||||
and [@../../../../boost/utility/typed_in_place_factory.hpp `<boost/utility/typed_in_place_factory.hpp>`].
|
||||
|
||||
Essentially, these classes hold a sequence of actual parameters and a method to construct an object in place using these parameters.
|
||||
Each member of the family differs only in the number and type of the parameter list. The first family
|
||||
@@ -214,11 +214,11 @@ As you can see, the `in_place_factory` and `typed_in_place_factory` template cla
|
||||
the target type: in the first family, the type is given as a template argument to the apply member function while in the
|
||||
second it is given directly as part of the factory class.
|
||||
|
||||
When the container holds a unique non-polymorphic type, such as the case of [@boost:/doc/html/optional/index.html Boost.Optional],
|
||||
When the container holds a unique non-polymorphic type, such as the case of [@boost:/libs/optional/index.html Boost.Optional],
|
||||
it knows the exact dynamic-type of the contained object and can pass it to the `apply()` method of a non-typed factory.
|
||||
In this case, end users can use an `in_place_factory` instance which can be constructed without the type of the object to construct.
|
||||
|
||||
However, if the container holds heterogeneous or polymorphic objects, such as the case of [@boost:/doc/html/variant/index.html Boost.Variant],
|
||||
However, if the container holds heterogeneous or polymorphic objects, such as the case of [@boost:/libs/variant/index.html Boost.Variant],
|
||||
the dynamic-type of the object to be constructed must be known by the factory. In this case, end users must use a `typed_in_place_factory`
|
||||
instead.
|
||||
|
||||
@@ -236,7 +236,7 @@ The correct function overload must be based on the only distinctive and common
|
||||
characteristic of all the classes in each family: the base class.
|
||||
|
||||
Depending on the container class, you can use `enable_if` to generate the right overload, or use the following
|
||||
dispatch technique, which is used in the [@boost:/doc/html/optional/index.html Boost.Optional] class:
|
||||
dispatch technique, which is used in the [@boost:/libs/optional/index.html Boost.Optional] class:
|
||||
|
||||
|
||||
```
|
||||
@@ -306,7 +306,3 @@ Copyright Fernando Luis Cacciola Carballal, 2004
|
||||
|
||||
[endsect]
|
||||
[endsect]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
12
doc/main.qbk
12
doc/main.qbk
@@ -26,12 +26,16 @@
|
||||
[category generic]
|
||||
]
|
||||
|
||||
[template mdash[] '''— ''']
|
||||
[template indexterm1[term1] '''<indexterm><primary>'''[term1]'''</primary></indexterm>''']
|
||||
[template indexterm2[term1 term2] '''<indexterm><primary>'''[term1]'''</primary><secondary>'''[term2]'''</secondary></indexterm>''']
|
||||
[template mdash[]'''—''']
|
||||
[template ndash[]'''–''']
|
||||
[template sect[]'''§''']
|
||||
[template hellip[]'''…''']
|
||||
|
||||
[template indexterm1[term1]'''<indexterm><primary>'''[term1]'''</primary></indexterm>''']
|
||||
[template indexterm2[term1 term2]'''<indexterm><primary>'''[term1]'''</primary><secondary>'''[term2]'''</secondary></indexterm>''']
|
||||
|
||||
[template include_file[path][^<'''<ulink url="https://github.com/boostorg/utility/blob/master/include/'''[path]'''">'''[path]'''</ulink>'''>]]
|
||||
[template issue[n] '''<ulink url="https://github.com/boostorg/utility/issues/'''[n]'''">#'''[n]'''</ulink>''']
|
||||
[template issue[n]'''<ulink url="https://github.com/boostorg/utility/issues/'''[n]'''">#'''[n]'''</ulink>''']
|
||||
|
||||
[/ Named Requirements ]
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
[section Introduction]
|
||||
|
||||
The header [@../../../include/boost/operators.hpp `<boost/operators.hpp>`] supplies
|
||||
The header [@../../../../boost/operators.hpp `<boost/operators.hpp>`] supplies
|
||||
several sets of class templates in `namespace boost`. These templates define
|
||||
operators at namespace scope in terms of a minimal number of fundamental
|
||||
operators provided by the class.
|
||||
@@ -32,7 +32,7 @@ related operators can be defined in terms of others (e.g. `x >= y`
|
||||
is equivalent to `!(x < y)`).
|
||||
|
||||
Replicating this boilerplate for multiple classes is both tedious and
|
||||
error-prone. The [@../../../include/boost/operators.hpp `<boost/operators.hpp>`] templates
|
||||
error-prone. The [@../../../../boost/operators.hpp `<boost/operators.hpp>`] templates
|
||||
help by generating operators for you at namespace scope based on other
|
||||
operators you have defined in your class.
|
||||
|
||||
@@ -291,11 +291,12 @@ are:
|
||||
* [link table:indexable `indexable<>`]
|
||||
* Any composite operator template that includes at least one of the above
|
||||
|
||||
As Daniel Krugler pointed out, this technique violates 14.6.5/2 and is thus
|
||||
non-portable. The reasoning is, that the operators injected by the instantiation
|
||||
As Daniel Krugler pointed out, this technique violates C++11 [sect]14.6.5/2 \[temp.inject\]
|
||||
and is thus non-portable. The reasoning is, that the operators injected by the instantiation
|
||||
of e.g. `less_than_comparable<my_class>` can not be found by ADL according to the
|
||||
rules given by 3.4.2/2, since `my_class` is not an associated class of
|
||||
`less_than_comparable<my_class>`. Thus only use this technique if all else fails.
|
||||
rules given by C++11 [sect]3.4.2/2 \[basic.lookup.argdep\], since `my_class` is not
|
||||
an associated class of `less_than_comparable<my_class>`. Thus only use this technique
|
||||
if all else fails.
|
||||
|
||||
[#sec:portability]
|
||||
[h5 Requirement Portability]
|
||||
@@ -1098,22 +1099,26 @@ function return value (which is another unnamed object of type
|
||||
`T`). The standard doesn't generally allow the intermediate
|
||||
object to be optimized away:
|
||||
|
||||
["3.7.2/2: Automatic storage duration: If a named automatic object has initialization or a destructor with
|
||||
side effects, it shall not be destroyed before the end of its block,
|
||||
nor shall it be eliminated as an optimization even if it appears to be
|
||||
unused, except that a class object or its copy may be eliminated as
|
||||
specified in 12.8.]
|
||||
[:['C++11 [sect]3.7.3/3 \[basic.stc.auto\]: Automatic storage duration:] If a variable with automatic storage
|
||||
duration has initialization or a destructor with side effects, it shall not be destroyed before the end of
|
||||
its block, nor shall it be eliminated as an optimization even if it appears to be unused, except that a class
|
||||
object or its copy/move may be eliminated as specified in 12.8.]
|
||||
|
||||
The reference to 12.8 is important for us:
|
||||
The reference to [sect]12.8 is important for us:
|
||||
|
||||
["12.8/15: Copying class objects: (...) For a function with a class return type, if the expression in the
|
||||
return statement is the name of a local object, and the cv-unqualified
|
||||
type of the local object is the same as the function return type, an
|
||||
implementation is permitted to omit creating the temporary object to
|
||||
hold the function return value, even if the class copy constructor or
|
||||
destructor has side effects.]
|
||||
[:['C++11 [sect]12.8/31 \[class.copy\]: Copying and moving class objects:] When certain criteria are met, an implementation is allowed to omit the copy/move construction of a class
|
||||
object, even if the copy/move constructor and/or destructor for the object have side effects. ([hellip]) This elision of copy/move
|
||||
operations, called ['copy elision], is permitted in the following circumstances (which may be combined to
|
||||
eliminate multiple copies):
|
||||
|
||||
This optimization is known as the named return value optimization (NRVO),
|
||||
[mdash] in a `return` statement in a function with a class return type, when the expression is the name of a
|
||||
non-volatile automatic object (other than a function or catch-clause parameter) with the same cv-
|
||||
unqualified type as the function return type, the copy/move operation can be omitted by constructing
|
||||
the automatic object directly into the function's return value
|
||||
|
||||
([hellip])]
|
||||
|
||||
This optimization is known as the named return value optimization ([@https://en.cppreference.com/w/cpp/language/copy_elision#Non-mandatory_elision_of_copy.2Fmove_.28since_C.2B.2B11.29_operations NRVO]),
|
||||
which leads us to the following implementation for `operator+`:
|
||||
|
||||
```
|
||||
@@ -1142,14 +1147,15 @@ T operator+( T lhs, const T& rhs )
|
||||
The difference to the first implementation is that `lhs` is
|
||||
not taken as a constant reference used to create a copy; instead,
|
||||
`lhs` is a by-value parameter, thus it is already the copy
|
||||
needed. This allows another optimization (12.2/2) for some cases.
|
||||
needed. This allows another optimization (C++11 [sect]12.2/2 \[class.temporary\])
|
||||
for some cases.
|
||||
|
||||
Consider `a + b + c` where the result of `a + b` is not copied when
|
||||
used as `lhs` when adding `c`. This is more efficient than the original
|
||||
code, but not as efficient as a compiler using the NRVO. For most people,
|
||||
it is still preferable for compilers that don't implement the NRVO, but
|
||||
the `operator+` now has a different function signature. Also,
|
||||
the number of objects created differs for `(a + b ) + c` and `a + ( b + c )`.
|
||||
the number of objects created differs for `(a + b) + c` and `a + (b + c)`.
|
||||
|
||||
Most probably, this won't be a problem for you, but if your code relies on the function
|
||||
signature or a strict symmetric behaviour, you should set
|
||||
@@ -1835,16 +1841,16 @@ such as `iterator_category` and `value_type`.
|
||||
|
||||
# [#note:1] Unlike other iterator helpers templates, __output_iterator_helper__ takes only one template parameter -
|
||||
the type of its target class. Although to some it might seem like an unnecessary restriction, the standard requires
|
||||
`difference_type` and `value_type` of any output iterator to be `void` (24.3.1 [lib.iterator.traits]), and
|
||||
`difference_type` and `value_type` of any output iterator to be `void` (C++11 [sect]24.4.1 \[lib.iterator.traits\]), and
|
||||
__output_iterator_helper__ template respects this requirement. Also, output iterators in the standard have void `pointer` and
|
||||
`reference` types, so the __output_iterator_helper__ does the same.
|
||||
# [#note:2] As self-proxying is the easiest and most common way to implement output iterators (see,
|
||||
for example, insert [24.4.2] and stream iterators [24.5] in the standard library),
|
||||
for example, insert (C++11 [sect]24.5.2 \[insert.iterators\]) and stream iterators (C++11 [sect]24.6 \[stream.iterators\]) in the standard library),
|
||||
__output_iterator_helper__ supports the idiom by defining `operator*` and `operator++` member functions which
|
||||
just return a non-const reference to the iterator itself. Support for self-proxying allows us, in many cases,
|
||||
to reduce the task of writing an output iterator to writing just two member functions - an appropriate
|
||||
constructor and a copy-assignment operator. For example, here is a possible implementation of
|
||||
[@boost:/doc/html/iterator/doc/function_output_iterator.html `boost::function_output_iterator`] adaptor:
|
||||
[@boost:/libs/iterator/doc/function_output_iterator.html `boost::function_output_iterator`] adaptor:
|
||||
|
||||
```
|
||||
template<class UnaryFunction>
|
||||
@@ -1936,11 +1942,11 @@ classes themselves have no state. For instance, the size of
|
||||
above was 12-24 bytes on various compilers for the Win32 platform,
|
||||
instead of the expected 8 bytes.
|
||||
|
||||
Strictly speaking, it was not the library's fault -- the language rules
|
||||
allow the compiler to apply the empty base class optimization in that
|
||||
situation. In principle an arbitrary number of empty base classes can be
|
||||
allocated at the same offset, provided that none of them have a common
|
||||
ancestor (see section 10.5 [class.derived] paragraph 5 of the standard).
|
||||
Strictly speaking, it was not the library's fault [ndash] the language rules
|
||||
allow the compiler to apply the [@https://en.cppreference.com/w/cpp/language/ebo empty base class optimization]
|
||||
in that situation. In principle an arbitrary number of empty base classes can
|
||||
be allocated at the same offset, provided that none of them have a common
|
||||
ancestor (see [sect]10 \[class.derived\] paragraph 8 of the C++11 standard).
|
||||
|
||||
But the language definition also does not ['require] implementations
|
||||
to do the optimization, and few if any of today's compilers implement it
|
||||
@@ -1949,7 +1955,7 @@ that implementors will adopt it as a future enhancement to existing
|
||||
compilers, because it would break binary compatibility between code
|
||||
generated by two different versions of the same compiler. As Matt Austern
|
||||
said, "One of the few times when you have the freedom to do this sort of
|
||||
thing is when you are targeting a new architecture...". On the other hand,
|
||||
thing is when you are targeting a new architecture[hellip]". On the other hand,
|
||||
many common compilers will use the empty base optimization for single
|
||||
inheritance hierarchies.
|
||||
|
||||
@@ -1971,11 +1977,11 @@ library to remain backward-compatible.
|
||||
|
||||
* [@http://www.boost.org/people/dave_abrahams.htm Dave Abrahams]:
|
||||
Started the library and contributed the arithmetic operators in
|
||||
[@../../../include/boost/operators.hpp `boost/operators.hpp`].
|
||||
[@../../../../boost/operators.hpp `boost/operators.hpp`].
|
||||
|
||||
* [@http://www.boost.org/people/jeremy_siek.htm Jeremy Siek]:
|
||||
Contributed the [link sec:deref dereference operators and iterator
|
||||
helpers] in [@../../../include/boost/operators.hpp boost/operators.hpp].
|
||||
helpers] in [@../../../../boost/operators.hpp boost/operators.hpp].
|
||||
Also contributed [@../../../test/iterators_test.cpp iterators_test.cpp].
|
||||
|
||||
* [@http://www.boost.org/people/aleksey_gurtovoy.htm Aleksey Gurtovoy]:
|
||||
|
||||
@@ -11,20 +11,19 @@
|
||||
|
||||
Some utilities have been moved from Boost.Utilities to more appropriate Boost libraries:
|
||||
|
||||
# Moved to [@boost:/doc/html/core/index.html Boost.Core]
|
||||
# [@boost:/doc/html/core/doc/html/core/addressof.html addressof]
|
||||
# [@boost:/doc/html/core/doc/html/core/checked_delete.html checked_delete]
|
||||
# [@boost:/doc/html/core/doc/html/core/enable_if.html enable_if]
|
||||
# [@boost:/doc/html/core/doc/html/core/noncopyable.html noncopyable]
|
||||
# Moved to [@boost:/doc/html/type_traits/index.html Boost.TypeTraits]
|
||||
# [@boost:/doc/html/type_traits/doc/html/boost_typetraits/reference/declval.html declval]
|
||||
# Moved to [@boost:/doc/html/iterator/index.html Boost.Iterator]
|
||||
# [@boost:/doc/html/iterator/doc/generator_iterator.htm generator iterator adaptors]
|
||||
# [@boost:/doc/html/iterator/doc/html/iterator/algorithms/next_prior.html next/prior]
|
||||
# Moved to [@boost:/doc/html/io/index.html Boost.IO]
|
||||
# [@boost:/doc/html/io/doc/html/io.html ostream_string]
|
||||
# Moved to [@boost:/doc/html/throw_exception/index.html Boost.ThrowException]
|
||||
# [@boost:/doc/html/throw_exception/doc/html/throw_exception.html#using_boost_throw_exception throw_exception]
|
||||
# Moved to [@boost:/libs/core/index.html Boost.Core]
|
||||
# [@boost:/libs/core/doc/html/core/addressof.html addressof]
|
||||
# [@boost:/libs/core/doc/html/core/checked_delete.html checked_delete]
|
||||
# [@boost:/libs/core/doc/html/core/enable_if.html enable_if]
|
||||
# [@boost:/libs/core/doc/html/core/noncopyable.html noncopyable]
|
||||
# Moved to [@boost:/libs/type_traits/index.html Boost.TypeTraits]
|
||||
# [@boost:/libs/type_traits/doc/html/boost_typetraits/reference/declval.html declval]
|
||||
# Moved to [@boost:/libs/iterator/index.html Boost.Iterator]
|
||||
# [@boost:/libs/iterator/doc/generator_iterator.htm generator iterator adaptors]
|
||||
# [@boost:/libs/iterator/doc/html/iterator/algorithms/next_prior.html next/prior]
|
||||
# Moved to [@boost:/libs/io/index.html Boost.IO]
|
||||
# [@boost:/libs/io/doc/html/io.html ostream_string]
|
||||
# Moved to [@boost:/libs/throw_exception/index.html Boost.ThrowException]
|
||||
# [@boost:/libs/throw_exception/doc/html/throw_exception.html#using_boost_throw_exception throw_exception]
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
@@ -22,24 +22,24 @@ in other libraries.
|
||||
|
||||
[table:id Components
|
||||
[[Boost.Utility] [Moved to Boost] [C++ Standard variant]]
|
||||
[[[@boost:/doc/html/core/doc/html/core/addressof.html `addressof`]] [[@boost:/doc/html/core/index.html Boost.Core]] [C++11 __std_addressof__]]
|
||||
[[[@boost:/libs/core/doc/html/core/addressof.html `addressof`]] [[@boost:/libs/core/index.html Boost.Core]] [C++11 __std_addressof__]]
|
||||
[[__base_from_member__] [] []]
|
||||
[[__BOOST_BINARY__] [] [C++14 [@https://en.cppreference.com/w/cpp/language/integer_literal Binary integer literal]]]
|
||||
[[__call_traits__] [] []]
|
||||
[[[@boost:/doc/html/core/doc/html/core/checked_delete.html `checked_delete`]] [[@boost:/doc/html/core/index.html Boost.Core]] []]
|
||||
[[[@boost:/libs/core/doc/html/core/checked_delete.html `checked_delete`]] [[@boost:/libs/core/index.html Boost.Core]] []]
|
||||
[[__compressed_pair__] [] []]
|
||||
[[[@boost:/doc/html/type_traits/doc/html/boost_typetraits/reference/declval.html `declval`]] [[@boost:/doc/html/type_traits/index.html Boost.TypeTraits]] [C++11 __std_declval__]]
|
||||
[[[@boost:/doc/html/core/doc/html/core/enable_if.html `enable_if`]] [[@boost:/doc/html/core/index.html Boost.Core]] [C++11 __std_enable_if__]]
|
||||
[[[@boost:/doc/html/iterator/doc/generator_iterator.htm generator iterator adaptors]] [[@boost:/doc/html/iterator/index.html Boost.Iterator]] []]
|
||||
[[[@boost:/libs/type_traits/doc/html/boost_typetraits/reference/declval.html `declval`]] [[@boost:/libs/type_traits/index.html Boost.TypeTraits]] [C++11 __std_declval__]]
|
||||
[[[@boost:/libs/core/doc/html/core/enable_if.html `enable_if`]] [[@boost:/libs/core/index.html Boost.Core]] [C++11 __std_enable_if__]]
|
||||
[[[@boost:/libs/iterator/doc/generator_iterator.htm generator iterator adaptors]] [[@boost:/libs/iterator/index.html Boost.Iterator]] []]
|
||||
[[__in_place_factory__] [] []]
|
||||
[[[@boost:/doc/html/iterator/index.html `iterator_adaptors`]] [[@boost:/doc/html/iterator/index.html Boost.Iterator]] []]
|
||||
[[[@boost:/doc/html/iterator/doc/html/iterator/algorithms/next_prior.html `next` / `prior`]] [[@boost:/doc/html/iterator/index.html Boost.Iterator]] [C++11 __std_next__ / __std_prev__]]
|
||||
[[[@boost:/doc/html/core/doc/html/core/noncopyable.html `noncopyable`]] [[@boost:/doc/html/core/index.html Boost.Core]] []]
|
||||
[[[@boost:/libs/iterator/index.html `iterator_adaptors`]] [[@boost:/libs/iterator/index.html Boost.Iterator]] []]
|
||||
[[[@boost:/libs/iterator/doc/html/iterator/algorithms/next_prior.html `next` / `prior`]] [[@boost:/libs/iterator/index.html Boost.Iterator]] [C++11 __std_next__ / __std_prev__]]
|
||||
[[[@boost:/libs/core/doc/html/core/noncopyable.html `noncopyable`]] [[@boost:/libs/core/index.html Boost.Core]] []]
|
||||
[[[link sec:operators `operators`]] [] []]
|
||||
[[[@boost:/doc/html/io/doc/html/io.html `ostream_string`]] [[@boost:/doc/html/io/index.html Boost.IO]] []]
|
||||
[[[@boost:/libs/io/doc/html/io.html `ostream_string`]] [[@boost:/libs/io/index.html Boost.IO]] []]
|
||||
[[__result_of__] [] [C++11 __std_result_of__]]
|
||||
[[__string_view__] [] [C++17 __std_string_view__]]
|
||||
[[[@boost:/doc/html/throw_exception/doc/html/throw_exception.html#using_boost_throw_exception `throw_exception`]] [[@boost:/doc/html/throw_exception/index.html Boost.ThrowException]] []]
|
||||
[[[@boost:/libs/throw_exception/doc/html/throw_exception.html#using_boost_throw_exception `throw_exception`]] [[@boost:/libs/throw_exception/index.html Boost.ThrowException]] []]
|
||||
[[[link sec:value_init `value_init`]] [] [C++11 [@https://en.cppreference.com/w/cpp/language/list_initialization List initialization]]]
|
||||
]
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ function reference, member function pointer, or class type. By default,
|
||||
N may be any value between 0 and 16. To change the upper limit, define
|
||||
the macro `BOOST_RESULT_OF_NUM_ARGS` to the maximum value for N. Class
|
||||
template __result_of__ resides in the header
|
||||
[@../../../include/boost/utility/result_of.hpp `<boost/utility/result_of.hpp>`].
|
||||
[@../../../../boost/utility/result_of.hpp `<boost/utility/result_of.hpp>`].
|
||||
|
||||
If your compiler's support for __decltype__ is adequate, __result_of__
|
||||
automatically uses it to deduce the type of the call expression, in
|
||||
@@ -419,5 +419,3 @@ Created by Doug Gregor. Contributions from Daniel Walker, Eric Niebler, Michel M
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
|
||||
@@ -37,17 +37,17 @@ Boost.Utility also includes the class __string_ref__:
|
||||
- __string_ref__ is the initial implementation of Jeffrey Yaskin's [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3442.html N3442:
|
||||
string_ref: a non-owning reference to a string].
|
||||
|
||||
- __string_view__ is an updated implementation to reflect the Library Fundamentals TS [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4480.html N4480: \[string.view\]]
|
||||
- __string_view__ is an updated implementation to reflect the Library Fundamentals TS [@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4480.html N4480: \[string.view\]].
|
||||
|
||||
Please prefer __string_view__ / __basic_string_view__ over __string_ref__ / __basic_string_ref__:
|
||||
|
||||
- The __basic_string_view__ class better matches __std_basic_string_view__
|
||||
- The __basic_string_view__ class better matches __std_basic_string_view__.
|
||||
|
||||
- __basic_string_view__ has WAY more constexpr support.
|
||||
|
||||
- Code that uses __basic_string_ref__ should continue to work.
|
||||
|
||||
- No much code depends on __basic_string_ref__ anymore
|
||||
- Not much code depends on __basic_string_ref__ anymore.
|
||||
|
||||
|
||||
]
|
||||
@@ -93,7 +93,7 @@ No memory allocations. No copying of character data. No changes to the code othe
|
||||
[section:reference Synopsis]
|
||||
[/=================]
|
||||
|
||||
The header file [@../../../include/boost/utility/string_view.hpp `<boost/utility/string_view.hpp>`] defines a template __boost_basic_string_view__, and four specializations __string_view__, __wstring_view__, __u16string_view__, __u32string_view__ - for `char` / `wchar_t` / `char16_t` / `char32_t`.
|
||||
The header file [@../../../../boost/utility/string_view.hpp `<boost/utility/string_view.hpp>`] defines a template __boost_basic_string_view__, and four specializations __string_view__, __wstring_view__, __u16string_view__, __u32string_view__ - for `char` / `wchar_t` / `char16_t` / `char32_t`.
|
||||
|
||||
`#include <boost/utility/string_view.hpp>`
|
||||
|
||||
@@ -207,4 +207,3 @@ Copyright 2012 Marshall Clow
|
||||
[endsect]
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
@@ -13,14 +13,12 @@ The entire contents of Boost.Utility are in `namespace boost`.
|
||||
|
||||
[warning
|
||||
|
||||
Direct use of the header [@../../../include/boost/utility.hpp `<boost/utility.hpp>`] is discouraged and it will be deprecated.
|
||||
Direct use of the header [@../../../../boost/utility.hpp `<boost/utility.hpp>`] is discouraged and it will be deprecated.
|
||||
|
||||
Please include the headers relative to individual components instead.
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
[include base_from_member.qbk]
|
||||
[include BOOST_BINARY.qbk]
|
||||
[include call_traits.qbk]
|
||||
@@ -32,4 +30,3 @@ Please include the headers relative to individual components instead.
|
||||
[include value_init.qbk]
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
@@ -109,14 +109,14 @@ but robust against the aforementioned compiler issues.
|
||||
The C++ standard \[[link sec:references 3]\] contains the definitions
|
||||
of `zero-initialization` and `default-initialization`. Informally, zero-initialization
|
||||
means that the object is given the initial value `0` converted to the type and
|
||||
default-initialization means that POD \[[link sec:references 4]\] types are zero-initialized,
|
||||
default-initialization means that [@https://en.cppreference.com/w/cpp/named_req/PODType POD] \[[link sec:references 4]\] types are zero-initialized,
|
||||
while non-POD class types are initialized with their corresponding default constructors.
|
||||
|
||||
A ['declaration] can contain an ['initializer], which specifies the
|
||||
object's initial value. The initializer can be just '()', which states that
|
||||
the object shall be value-initialized (but see below). However, if a ['declaration]
|
||||
has no ['initializer] and it is of a non-`const`, non-`static` POD type, the
|
||||
initial value is indeterminate: (see §8.5, [dcl.init], for the
|
||||
initial value is indeterminate: (see [sect]8.5, \[dcl.init\], for the
|
||||
accurate definitions).
|
||||
|
||||
```
|
||||
@@ -262,7 +262,7 @@ is fixed.
|
||||
New versions of __value_initialized__ (Boost release version 1.35 or higher) offer a workaround to these
|
||||
issues: __value_initialized__ may now clear its internal data, prior to constructing the object that it
|
||||
contains. It will do so for those compilers that need to have such a workaround, based on the
|
||||
[@boost:/doc/html/config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_defects
|
||||
[@boost:/libs/config/doc/html/boost_config/boost_macro_reference.html#boost_config.boost_macro_reference.macros_that_describe_defects
|
||||
compiler defect macro] `BOOST_NO_COMPLETE_VALUE_INITIALIZATION`.
|
||||
|
||||
[endsect]
|
||||
@@ -553,7 +553,7 @@ compiler-generated functions you do not want], [@http://www.aristeia.com/books.h
|
||||
|
||||
# The C++ Standard, Second edition (2003), ISO/IEC 14882:2003
|
||||
|
||||
# POD stands for "Plain Old Data"
|
||||
# POD stands for [@https://en.cppreference.com/w/cpp/named_req/PODType "Plain Old Data"]
|
||||
|
||||
[endsect]
|
||||
|
||||
|
||||
@@ -119,8 +119,8 @@ template<typename F> struct cpp0x_result_of;
|
||||
|
||||
// There doesn't seem to be any other way to turn this off such that the presence of
|
||||
// the user-defined operator,() below doesn't cause spurious warning all over the place,
|
||||
// so unconditionally turn it off.
|
||||
#if BOOST_MSVC
|
||||
// so unconditionally and globally turn it off. (https://svn.boost.org/trac10/ticket/7663)
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(disable: 4913) // user defined binary operator ',' exists but no overload could convert all operands, default built-in binary operator ',' used
|
||||
#endif
|
||||
|
||||
@@ -134,12 +134,19 @@ template<typename T>
|
||||
result_of_no_type result_of_is_private_type(T const &);
|
||||
result_of_yes_type result_of_is_private_type(result_of_private_type);
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4512) // assignment operator could not be generated.
|
||||
#endif
|
||||
template<typename C>
|
||||
struct result_of_callable_class : C {
|
||||
result_of_callable_class();
|
||||
typedef result_of_private_type const &(*pfn_t)(...);
|
||||
operator pfn_t() const volatile;
|
||||
};
|
||||
#ifdef BOOST_MSVC
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
template<typename C>
|
||||
struct result_of_wrap_callable_class {
|
||||
|
||||
Reference in New Issue
Block a user