forked from boostorg/optional
Compare commits
16 Commits
boost-1.58
...
boost-1.60
Author | SHA1 | Date | |
---|---|---|---|
ede89602f7 | |||
9273fb435f | |||
1dd2c422ca | |||
02ed4eadd8 | |||
593710e961 | |||
4beeba5420 | |||
b43ce289c2 | |||
9b1894a2f3 | |||
4be4646ddd | |||
5ece1f224a | |||
95a073f061 | |||
4e7405a233 | |||
ff90f939ed | |||
8ca74951b0 | |||
339202a8fb | |||
1d7fe0e770 |
@ -15,14 +15,16 @@
|
||||
```
|
||||
namespace boost {
|
||||
|
||||
class none_t {};
|
||||
class none_t {/* see below */};
|
||||
|
||||
extern const none_t none; // see below
|
||||
const none_t none (/* see below */);
|
||||
|
||||
} // namespace boost
|
||||
```
|
||||
|
||||
Variable `none` has external linkage, however it is not required to link with any library to obtain its definition. Only by including this header file, the definition becomes available, by means of using template instantiation.
|
||||
Class `none_t` is meant to serve as a tag for selecting appropriate overloads of from `optional`'s interface. It is an empty, trivially copyable class with disabled default constructor.
|
||||
|
||||
Constant `none` is used to indicate an optional object that does not contain a value in initialization, assignment and relational operations of `optional`.
|
||||
|
||||
[endsect]
|
||||
|
||||
|
@ -463,10 +463,11 @@ __SPACE__
|
||||
|
||||
* [*Requires:] `T` is __COPY_CONSTRUCTIBLE__ and `CopyAssignable`.
|
||||
* [*Effects:]
|
||||
[table
|
||||
[[][`*this` contains a value][`*this` does not contain a value]]
|
||||
[[`rhs` contains a value][assigns `*rhs` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `*rhs`]]
|
||||
[[`rhs` does not contain a value][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||
[table
|
||||
[]
|
||||
[[][[*`*this` contains a value]][[*`*this` does not contain a value]]]
|
||||
[[[*`rhs` contains a value]][assigns `*rhs` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `*rhs`]]
|
||||
[[[*`rhs` does not contain a value]][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||
]
|
||||
* [*Returns:] `*this`;
|
||||
* [*Postconditions:] `bool(rhs) == bool(*this)`.
|
||||
@ -525,9 +526,10 @@ __SPACE__
|
||||
* [*Requires:] `T` is __MOVE_CONSTRUCTIBLE__ and `MoveAssignable`.
|
||||
* [*Effects:]
|
||||
[table
|
||||
[[][`*this` contains a value][`*this` does not contain a value]]
|
||||
[[`rhs` contains a value][assigns `std::move(*rhs)` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `std::move(*rhs)`]]
|
||||
[[`rhs` does not contain a value][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||
[]
|
||||
[[][[*`*this` contains a value]][[*`*this` does not contain a value]]]
|
||||
[[[*`rhs` contains a value]][assigns `std::move(*rhs)` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `std::move(*rhs)`]]
|
||||
[[[*`rhs` does not contain a value]][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||
]
|
||||
* [*Returns:] `*this`;
|
||||
* [*Postconditions:] `bool(rhs) == bool(*this)`.
|
||||
@ -561,9 +563,10 @@ __SPACE__
|
||||
|
||||
* [*Effect:]
|
||||
[table
|
||||
[[][`*this` contains a value][`*this` does not contain a value]]
|
||||
[[`rhs` contains a value][assigns `*rhs` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `*rhs`]]
|
||||
[[`rhs` does not contain a value][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||
[]
|
||||
[[][[*`*this` contains a value]][[*`*this` does not contain a value]]]
|
||||
[[[*`rhs` contains a value]][assigns `*rhs` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `*rhs`]]
|
||||
[[[*`rhs` does not contain a value]][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||
]
|
||||
* [*Returns:] `*this`.
|
||||
* [*Postconditions:] `bool(rhs) == bool(*this)`.
|
||||
@ -587,10 +590,11 @@ __SPACE__
|
||||
[: `template<U> optional& optional<T` ['(not a ref)]`>::operator= ( optional<U>&& rhs ) ;`]
|
||||
|
||||
* [*Effect:]
|
||||
[table
|
||||
[[][`*this` contains a value][`*this` does not contain a value]]
|
||||
[[`rhs` contains a value][assigns `std::move(*rhs)` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `std::move(*rhs)`]]
|
||||
[[`rhs` does not contain a value][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||
[table
|
||||
[]
|
||||
[[][[*`*this` contains a value]][[*`*this` does not contain a value]]]
|
||||
[[[*`rhs` contains a value]][assigns `std::move(*rhs)` to the contained value][initializes the contained value as if direct-initializing an object of type `T` with `std::move(*rhs)`]]
|
||||
[[[*`rhs` does not contain a value]][destroys the contained value by calling `val->T::~T()`][no effect]]
|
||||
]
|
||||
* [*Returns:] `*this`.
|
||||
* [*Postconditions:] `bool(rhs) == bool(*this)`.
|
||||
@ -621,8 +625,10 @@ __SPACE__
|
||||
of type `T` with `std::forward<Args>(args)...`.
|
||||
* [*Postconditions: ] `*this` is [_initialized].
|
||||
* [*Throws:] Whatever the selected `T`'s constructor throws.
|
||||
* [*Notes:] `T` need not be __MOVE_CONSTRUCTIBLE__ or `MoveAssignable`. On compilers that do not support variadic templates, the signature falls back to single-argument: `template<class Arg> void emplace(Arg&& arg)`. On compilers that do not support rvalue references, the signature falls back to two overloads: taking `const` and non-`const` lvalue reference.
|
||||
* [*Exception Safety:] If an exception is thrown during the initialization of `T`, `*this` is ['uninitialized].
|
||||
* [*Notes:] `T` need not be __MOVE_CONSTRUCTIBLE__ or `MoveAssignable`.
|
||||
On compilers that do not support variadic templates, the signature falls back to two overloads:`template<class Arg> void emplace(Arg&& arg)` and `void emplace()`.
|
||||
On compilers that do not support rvalue references, the signature falls back to three overloads: taking `const` and non-`const` lvalue reference, and third with empty function argument list.
|
||||
* [*Example:]
|
||||
``
|
||||
T v;
|
||||
@ -1111,9 +1117,10 @@ __SPACE__
|
||||
* [*Requires:] Lvalues of type `T` shall be swappable and `T` shall be __MOVE_CONSTRUCTIBLE__.
|
||||
* [*Effects:]
|
||||
[table
|
||||
[[][`*this` contains a value][`*this` does not contain a value]]
|
||||
[[`rhs` contains a value][calls `swap(*(*this), *rhs)`][initializes the contained value of `*this` as if direct-initializing an object of type `T` with the expression `std::move(*rhs)`, followed by `rhs.val->T::~T()`, `*this` contains a value and `rhs` does not contain a value]]
|
||||
[[`rhs` does not contain a value][initializes the contained value of `rhs` as if direct-initializing an object of type `T` with the expression `std::move(*(*this))`, followed by `val->T::~T()`, `*this` does not contain a value and `rhs` contains a value][no effect]]
|
||||
[]
|
||||
[[][[*`*this` contains a value]][[*`*this` does not contain a value]]]
|
||||
[[[*`rhs` contains a value]][calls `swap(*(*this), *rhs)`][initializes the contained value of `*this` as if direct-initializing an object of type `T` with the expression `std::move(*rhs)`, followed by `rhs.val->T::~T()`, `*this` contains a value and `rhs` does not contain a value]]
|
||||
[[[*`rhs` does not contain a value]][initializes the contained value of `rhs` as if direct-initializing an object of type `T` with the expression `std::move(*(*this))`, followed by `val->T::~T()`, `*this` does not contain a value and `rhs` contains a value][no effect]]
|
||||
]
|
||||
* [*Postconditions:] The states of `x` and `y` interchanged.
|
||||
* [*Throws:] If both are initialized, whatever `swap(T&,T&)` throws. If only
|
||||
|
@ -11,12 +11,21 @@
|
||||
|
||||
[section:relnotes Release Notes]
|
||||
|
||||
[heading Boost Release 1.60]
|
||||
|
||||
* Changed the implementation of `boost::none` again. Now it is a const object with internal linkage (as any other tag). This fixes [@https://svn.boost.org/trac/boost/ticket/11203 Trac #11203].
|
||||
|
||||
[heading Boost Release 1.59]
|
||||
|
||||
* For C++03 compilers, added 0-argument overload for member function `emplace()`, and therewith removed the dependency on `<boost/utility/in_place_factory.hpp>`.
|
||||
* Fixed [@https://svn.boost.org/trac/boost/ticket/11241 Trac #11241].
|
||||
|
||||
[heading Boost Release 1.58]
|
||||
|
||||
* `boost::none_t` is no longer convertible from literal `0`. This avoids a bug where `optional<rational<int>> oi = 0;` would initialize an optional object with no contained value.
|
||||
* Improved the trick that prevents streaming out `optional` without header `optional_io.hpp` by using safe-bool idiom. This addresses [@https://svn.boost.org/trac/boost/ticket/10825 Trac #10825]
|
||||
* Improved the trick that prevents streaming out `optional` without header `optional_io.hpp` by using safe-bool idiom. This addresses [@https://svn.boost.org/trac/boost/ticket/10825 Trac #10825].
|
||||
* IOStream operators are now mentioned in documentation.
|
||||
* Added a way to manually disable move semantics: just define macro `BOOST_OPTIONAL_CONFIG_NO_RVALUE_REFERENCES`. This can be used to work around [@https://svn.boost.org/trac/boost/ticket/10399 Trac #10399]
|
||||
* Added a way to manually disable move semantics: just define macro `BOOST_OPTIONAL_CONFIG_NO_RVALUE_REFERENCES`. This can be used to work around [@https://svn.boost.org/trac/boost/ticket/10399 Trac #10399].
|
||||
* It is no longer possible to assign `optional<U>` to `optional<T>` when `U` is not assignable or convertible to `T` ([@https://svn.boost.org/trac/boost/ticket/11087 Trac #11087]).
|
||||
* Value accessors now work correctly on rvalues of `optional<T&>` ([@https://svn.boost.org/trac/boost/ticket/10839 Trac #10839]).
|
||||
|
||||
|
@ -838,28 +838,27 @@
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||
contains a value
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||
does not contain a value
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<thead><tr></tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">rhs</span></code> contains
|
||||
a value
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> contains a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> does not contain a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||
contains a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
@ -879,8 +878,8 @@
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">rhs</span></code> does
|
||||
not contain a value
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||
does not contain a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
@ -995,28 +994,27 @@
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||
contains a value
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||
does not contain a value
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<thead><tr></tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">rhs</span></code> contains
|
||||
a value
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> contains a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> does not contain a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||
contains a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
@ -1035,8 +1033,8 @@
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">rhs</span></code> does
|
||||
not contain a value
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||
does not contain a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
@ -1117,28 +1115,27 @@
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||
contains a value
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||
does not contain a value
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<thead><tr></tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">rhs</span></code> contains
|
||||
a value
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> contains a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> does not contain a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||
contains a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
@ -1158,8 +1155,8 @@
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">rhs</span></code> does
|
||||
not contain a value
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||
does not contain a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
@ -1222,28 +1219,27 @@
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||
contains a value
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||
does not contain a value
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<thead><tr></tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">rhs</span></code> contains
|
||||
a value
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> contains a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> does not contain a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||
contains a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
@ -1262,8 +1258,8 @@
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">rhs</span></code> does
|
||||
not contain a value
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||
does not contain a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
@ -1336,23 +1332,26 @@
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Throws:</strong></span> Whatever the selected <code class="computeroutput"><span class="identifier">T</span></code>'s constructor throws.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Notes:</strong></span> <code class="computeroutput"><span class="identifier">T</span></code>
|
||||
need not be <code class="computeroutput"><span class="identifier">MoveConstructible</span></code>
|
||||
or <code class="computeroutput"><span class="identifier">MoveAssignable</span></code>.
|
||||
On compilers that do not support variadic templates, the signature
|
||||
falls back to single-argument: <code class="computeroutput"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span>
|
||||
<span class="identifier">Arg</span><span class="special">></span>
|
||||
<span class="keyword">void</span> <span class="identifier">emplace</span><span class="special">(</span><span class="identifier">Arg</span><span class="special">&&</span> <span class="identifier">arg</span><span class="special">)</span></code>. On compilers that do not support
|
||||
rvalue references, the signature falls back to two overloads: taking
|
||||
<code class="computeroutput"><span class="keyword">const</span></code> and non-<code class="computeroutput"><span class="keyword">const</span></code> lvalue reference.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Exception Safety:</strong></span> If an exception
|
||||
is thrown during the initialization of <code class="computeroutput"><span class="identifier">T</span></code>,
|
||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||
is <span class="emphasis"><em>uninitialized</em></span>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Notes:</strong></span> <code class="computeroutput"><span class="identifier">T</span></code>
|
||||
need not be <code class="computeroutput"><span class="identifier">MoveConstructible</span></code>
|
||||
or <code class="computeroutput"><span class="identifier">MoveAssignable</span></code>.
|
||||
On compilers that do not support variadic templates, the signature
|
||||
falls back to two overloads:<code class="computeroutput"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span>
|
||||
<span class="identifier">Arg</span><span class="special">></span>
|
||||
<span class="keyword">void</span> <span class="identifier">emplace</span><span class="special">(</span><span class="identifier">Arg</span><span class="special">&&</span> <span class="identifier">arg</span><span class="special">)</span></code> and <code class="computeroutput"><span class="keyword">void</span>
|
||||
<span class="identifier">emplace</span><span class="special">()</span></code>.
|
||||
On compilers that do not support rvalue references, the signature falls
|
||||
back to three overloads: taking <code class="computeroutput"><span class="keyword">const</span></code>
|
||||
and non-<code class="computeroutput"><span class="keyword">const</span></code> lvalue reference,
|
||||
and third with empty function argument list.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
<span class="bold"><strong>Example:</strong></span>
|
||||
<pre class="programlisting"><span class="identifier">T</span> <span class="identifier">v</span><span class="special">;</span>
|
||||
@ -2271,28 +2270,27 @@
|
||||
<col>
|
||||
<col>
|
||||
</colgroup>
|
||||
<thead><tr>
|
||||
<th>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||
contains a value
|
||||
</p>
|
||||
</th>
|
||||
<th>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code>
|
||||
does not contain a value
|
||||
</p>
|
||||
</th>
|
||||
</tr></thead>
|
||||
<thead><tr></tr></thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">rhs</span></code> contains
|
||||
a value
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> contains a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="special">*</span><span class="keyword">this</span></code> does not contain a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||
contains a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
@ -2314,8 +2312,8 @@
|
||||
<tr>
|
||||
<td>
|
||||
<p>
|
||||
<code class="computeroutput"><span class="identifier">rhs</span></code> does
|
||||
not contain a value
|
||||
<span class="bold"><strong><code class="computeroutput"><span class="identifier">rhs</span></code>
|
||||
does not contain a value</strong></span>
|
||||
</p>
|
||||
</td>
|
||||
<td>
|
||||
|
@ -28,6 +28,31 @@
|
||||
</h2></div></div></div>
|
||||
<h4>
|
||||
<a name="boost_optional.relnotes.h0"></a>
|
||||
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_60"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_60">Boost
|
||||
Release 1.60</a>
|
||||
</h4>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
|
||||
Changed the implementation of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">none</span></code>
|
||||
again. Now it is a const object with internal linkage (as any other tag).
|
||||
This fixes <a href="https://svn.boost.org/trac/boost/ticket/11203" target="_top">Trac
|
||||
#11203</a>.
|
||||
</li></ul></div>
|
||||
<h4>
|
||||
<a name="boost_optional.relnotes.h1"></a>
|
||||
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_59"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_59">Boost
|
||||
Release 1.59</a>
|
||||
</h4>
|
||||
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
|
||||
<li class="listitem">
|
||||
For C++03 compilers, added 0-argument overload for member function <code class="computeroutput"><span class="identifier">emplace</span><span class="special">()</span></code>,
|
||||
and therewith removed the dependency on <code class="computeroutput"><span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">utility</span><span class="special">/</span><span class="identifier">in_place_factory</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
Fixed <a href="https://svn.boost.org/trac/boost/ticket/11241" target="_top">Trac #11241</a>.
|
||||
</li>
|
||||
</ul></div>
|
||||
<h4>
|
||||
<a name="boost_optional.relnotes.h2"></a>
|
||||
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_58"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_58">Boost
|
||||
Release 1.58</a>
|
||||
</h4>
|
||||
@ -42,7 +67,7 @@
|
||||
Improved the trick that prevents streaming out <code class="computeroutput"><span class="identifier">optional</span></code>
|
||||
without header <code class="computeroutput"><span class="identifier">optional_io</span><span class="special">.</span><span class="identifier">hpp</span></code>
|
||||
by using safe-bool idiom. This addresses <a href="https://svn.boost.org/trac/boost/ticket/10825" target="_top">Trac
|
||||
#10825</a>
|
||||
#10825</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
IOStream operators are now mentioned in documentation.
|
||||
@ -50,7 +75,7 @@
|
||||
<li class="listitem">
|
||||
Added a way to manually disable move semantics: just define macro <code class="computeroutput"><span class="identifier">BOOST_OPTIONAL_CONFIG_NO_RVALUE_REFERENCES</span></code>.
|
||||
This can be used to work around <a href="https://svn.boost.org/trac/boost/ticket/10399" target="_top">Trac
|
||||
#10399</a>
|
||||
#10399</a>.
|
||||
</li>
|
||||
<li class="listitem">
|
||||
It is no longer possible to assign <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">U</span><span class="special">></span></code> to <code class="computeroutput"><span class="identifier">optional</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span></code> when <code class="computeroutput"><span class="identifier">U</span></code>
|
||||
@ -63,7 +88,7 @@
|
||||
</li>
|
||||
</ul></div>
|
||||
<h4>
|
||||
<a name="boost_optional.relnotes.h1"></a>
|
||||
<a name="boost_optional.relnotes.h3"></a>
|
||||
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_57"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_57">Boost
|
||||
Release 1.57</a>
|
||||
</h4>
|
||||
@ -73,7 +98,7 @@
|
||||
to fix C++03 compile error on <code class="computeroutput"><span class="identifier">logic_error</span><span class="special">(</span><span class="string">"..."</span><span class="special">)</span></code>"</em></span>.
|
||||
</li></ul></div>
|
||||
<h4>
|
||||
<a name="boost_optional.relnotes.h2"></a>
|
||||
<a name="boost_optional.relnotes.h4"></a>
|
||||
<span class="phrase"><a name="boost_optional.relnotes.boost_release_1_56"></a></span><a class="link" href="relnotes.html#boost_optional.relnotes.boost_release_1_56">Boost
|
||||
Release 1.56</a>
|
||||
</h4>
|
||||
|
@ -146,7 +146,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
|
||||
<td align="left"><p><small>Last revised: March 13, 2015 at 21:52:15 GMT</small></p></td>
|
||||
<td align="left"><p><small>Last revised: October 20, 2015 at 21:17:45 GMT</small></p></td>
|
||||
<td align="right"><div class="copyright-footer"></div></td>
|
||||
</tr></table>
|
||||
<hr>
|
||||
|
@ -52,19 +52,23 @@
|
||||
</p>
|
||||
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> <span class="special">{</span>
|
||||
|
||||
<span class="keyword">class</span> <span class="identifier">none_t</span> <span class="special">{};</span>
|
||||
<span class="keyword">class</span> <span class="identifier">none_t</span> <span class="special">{/*</span> <span class="identifier">see</span> <span class="identifier">below</span> <span class="special">*/};</span>
|
||||
|
||||
<span class="keyword">extern</span> <span class="keyword">const</span> <span class="identifier">none_t</span> <span class="identifier">none</span><span class="special">;</span> <span class="comment">// see below</span>
|
||||
<span class="keyword">const</span> <span class="identifier">none_t</span> <span class="identifier">none</span> <span class="special">(/*</span> <span class="identifier">see</span> <span class="identifier">below</span> <span class="special">*/);</span>
|
||||
|
||||
<span class="special">}</span> <span class="comment">// namespace boost</span>
|
||||
</pre>
|
||||
<p>
|
||||
</p>
|
||||
<p>
|
||||
Variable <code class="computeroutput"><span class="identifier">none</span></code> has external
|
||||
linkage, however it is not required to link with any library to obtain
|
||||
its definition. Only by including this header file, the definition becomes
|
||||
available, by means of using template instantiation.
|
||||
Class <code class="computeroutput"><span class="identifier">none_t</span></code> is meant to
|
||||
serve as a tag for selecting appropriate overloads of from <code class="computeroutput"><span class="identifier">optional</span></code>'s interface. It is an empty,
|
||||
trivially copyable class with disabled default constructor.
|
||||
</p>
|
||||
<p>
|
||||
Constant <code class="computeroutput"><span class="identifier">none</span></code> is used to
|
||||
indicate an optional object that does not contain a value in initialization,
|
||||
assignment and relational operations of <code class="computeroutput"><span class="identifier">optional</span></code>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -22,8 +22,10 @@
|
||||
namespace boost {
|
||||
|
||||
#ifdef BOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE
|
||||
|
||||
none_t const none = (static_cast<none_t>(0)) ;
|
||||
#else
|
||||
|
||||
#elif defined BOOST_OPTIONAL_USE_SINGLETON_DEFINITION_OF_NONE
|
||||
|
||||
namespace detail { namespace optional_detail {
|
||||
|
||||
@ -45,9 +47,13 @@ namespace {
|
||||
const none_t& none = detail::optional_detail::none_instance<none_t>::instance;
|
||||
}
|
||||
|
||||
#endif
|
||||
#else
|
||||
|
||||
const none_t none ((none_t::init_tag()));
|
||||
|
||||
#endif // older definitions
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
#endif // header guard
|
||||
|
||||
|
@ -16,13 +16,25 @@
|
||||
namespace boost {
|
||||
|
||||
#ifdef BOOST_OPTIONAL_USE_OLD_DEFINITION_OF_NONE
|
||||
|
||||
namespace detail { struct none_helper{}; }
|
||||
typedef int detail::none_helper::*none_t ;
|
||||
#else
|
||||
|
||||
#elif defined BOOST_OPTIONAL_USE_SINGLETON_DEFINITION_OF_NONE
|
||||
|
||||
class none_t {};
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
struct none_t
|
||||
{
|
||||
struct init_tag{};
|
||||
explicit none_t(init_tag){} // to prevent default constructor
|
||||
};
|
||||
|
||||
#endif // old implementation workarounds
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#endif
|
||||
#endif // header guard
|
||||
|
||||
|
@ -18,12 +18,14 @@
|
||||
#define BOOST_OPTIONAL_OPTIONAL_FLC_19NOV2002_HPP
|
||||
|
||||
#include <new>
|
||||
#include <algorithm>
|
||||
#include <iosfwd>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/core/addressof.hpp>
|
||||
#include <boost/core/enable_if.hpp>
|
||||
#include <boost/core/explicit_operator_bool.hpp>
|
||||
#include <boost/core/swap.hpp>
|
||||
#include <boost/optional/bad_optional_access.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
@ -47,13 +49,7 @@
|
||||
#include <boost/detail/reference_content.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/none.hpp>
|
||||
#include <boost/utility/addressof.hpp>
|
||||
#include <boost/utility/compare_pointees.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/utility/in_place_factory.hpp>
|
||||
#include <boost/utility/swap.hpp>
|
||||
|
||||
|
||||
|
||||
#include <boost/optional/optional_fwd.hpp>
|
||||
|
||||
@ -506,6 +502,13 @@ class optional_base : public optional_tag
|
||||
::new (m_storage.address()) internal_type( boost::forward<Arg>(arg) );
|
||||
m_initialized = true ;
|
||||
}
|
||||
|
||||
void emplace_assign ()
|
||||
{
|
||||
destroy();
|
||||
::new (m_storage.address()) internal_type();
|
||||
m_initialized = true ;
|
||||
}
|
||||
#else
|
||||
template<class Arg>
|
||||
void emplace_assign ( const Arg& arg )
|
||||
@ -515,13 +518,20 @@ class optional_base : public optional_tag
|
||||
m_initialized = true ;
|
||||
}
|
||||
|
||||
template<class Arg>
|
||||
template<class Arg>
|
||||
void emplace_assign ( Arg& arg )
|
||||
{
|
||||
destroy();
|
||||
::new (m_storage.address()) internal_type( arg );
|
||||
m_initialized = true ;
|
||||
}
|
||||
|
||||
void emplace_assign ()
|
||||
{
|
||||
destroy();
|
||||
::new (m_storage.address()) internal_type();
|
||||
m_initialized = true ;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
|
||||
@ -976,6 +986,11 @@ class optional : public optional_detail::optional_base<T>
|
||||
{
|
||||
this->emplace_assign( boost::forward<Arg>(arg) );
|
||||
}
|
||||
|
||||
void emplace ()
|
||||
{
|
||||
this->emplace_assign();
|
||||
}
|
||||
#else
|
||||
template<class Arg>
|
||||
void emplace ( const Arg& arg )
|
||||
@ -988,6 +1003,11 @@ class optional : public optional_detail::optional_base<T>
|
||||
{
|
||||
this->emplace_assign( arg );
|
||||
}
|
||||
|
||||
void emplace ()
|
||||
{
|
||||
this->emplace_assign();
|
||||
}
|
||||
#endif
|
||||
|
||||
void swap( optional & arg )
|
||||
@ -1251,9 +1271,10 @@ get_pointer ( optional<T>& opt )
|
||||
// The following declaration prevents a bug where operator safe-bool is used upon streaming optional object if you forget the IO header.
|
||||
template<class CharType, class CharTrait>
|
||||
std::basic_ostream<CharType, CharTrait>&
|
||||
operator<<(std::basic_ostream<CharType, CharTrait>& out, optional_detail::optional_tag const& v)
|
||||
operator<<(std::basic_ostream<CharType, CharTrait>& os, optional_detail::optional_tag const&)
|
||||
{
|
||||
BOOST_STATIC_ASSERT_MSG(sizeof(CharType) == 0, "If you want to output boost::optional, include header <boost/optional/optional_io.hpp>");
|
||||
BOOST_STATIC_ASSERT_MSG(sizeof(CharType) == 0, "If you want to output boost::optional, include header <boost/optional/optional_io.hpp>");
|
||||
return os;
|
||||
}
|
||||
|
||||
// optional's relational operators ( ==, !=, <, >, <=, >= ) have deep-semantics (compare values).
|
||||
@ -1448,9 +1469,9 @@ struct swap_selector<true>
|
||||
return;
|
||||
|
||||
if( !hasX )
|
||||
x = boost::in_place();
|
||||
x.emplace();
|
||||
else if ( !hasY )
|
||||
y = boost::in_place();
|
||||
y.emplace();
|
||||
|
||||
// Boost.Utility.Swap will take care of ADL and workarounds for broken compilers
|
||||
boost::swap(x.get(),y.get());
|
||||
@ -1523,9 +1544,18 @@ struct swap_selector<false>
|
||||
|
||||
} // namespace optional_detail
|
||||
|
||||
#if (!defined BOOST_NO_CXX11_RVALUE_REFERENCES) && (!defined BOOST_CONFIG_RESTORE_OBSOLETE_SWAP_IMPLEMENTATION)
|
||||
|
||||
template<class T>
|
||||
struct optional_swap_should_use_default_constructor : boost::false_type {} ;
|
||||
|
||||
#else
|
||||
|
||||
template<class T>
|
||||
struct optional_swap_should_use_default_constructor : has_nothrow_default_constructor<T> {} ;
|
||||
|
||||
#endif //BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
template<class T> inline void swap ( optional<T>& x, optional<T>& y )
|
||||
//BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && BOOST_NOEXCEPT_EXPR(boost::swap(*x, *y)))
|
||||
{
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
|
||||
#include <boost/none.hpp>
|
||||
#include "boost/none.hpp"
|
||||
#include "boost/optional/optional.hpp"
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ namespace boost
|
||||
template<class CharType, class CharTrait>
|
||||
inline
|
||||
std::basic_ostream<CharType, CharTrait>&
|
||||
operator<<(std::basic_ostream<CharType, CharTrait>& out, none_t const&)
|
||||
operator<<(std::basic_ostream<CharType, CharTrait>& out, none_t)
|
||||
{
|
||||
if (out.good())
|
||||
{
|
||||
|
@ -1,15 +1,16 @@
|
||||
# Boost.Optional Library test Jamfile
|
||||
# Boost.Optional Library test Jamfile
|
||||
#
|
||||
# Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
||||
# Copyright (C) 2003, Fernando Luis Cacciola Carballal.
|
||||
# Copyright (C) 2014, 2015 Andrzej Krzemienski
|
||||
#
|
||||
# This material is provided "as is", with absolutely no warranty expressed
|
||||
# or implied. Any use is at your own risk.
|
||||
# Use, modification, and distribution is 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)
|
||||
#
|
||||
# Permission to use or copy this software for any purpose is hereby granted
|
||||
# without fee, provided the above notices are retained on all copies.
|
||||
# Permission to modify the code and to distribute modified code is granted,
|
||||
# provided the above notices are retained, and a notice that the code was
|
||||
# modified is included with the above copyright notice.
|
||||
# See http://www.boost.org/libs/optional for documentation.
|
||||
#
|
||||
# You are welcome to contact the author at:
|
||||
# akrzemi1@gmail.com
|
||||
#
|
||||
|
||||
import testing ;
|
||||
@ -57,6 +58,7 @@ import testing ;
|
||||
[ compile-fail optional_test_fail_explicit_convert_in_value_or.cpp ]
|
||||
[ compile-fail optional_test_fail_explicit_convert_in_value_or_call.cpp ]
|
||||
[ compile-fail optional_test_fail_io_without_io.cpp ]
|
||||
[ compile-fail optional_test_fail_none_io_without_io.cpp ]
|
||||
[ compile-fail optional_test_fail_convert_assign_of_enums.cpp ]
|
||||
;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#include "boost/none.hpp"
|
||||
|
||||
#include "boost/test/minimal.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
|
||||
#include "optional_test_common.cpp"
|
||||
|
||||
@ -46,12 +46,12 @@ void test_implicit_construction ( optional<X> opt, X const& v, X const& z )
|
||||
|
||||
void test_default_implicit_construction ( double, optional<double> opt )
|
||||
{
|
||||
BOOST_CHECK(!opt);
|
||||
BOOST_TEST(!opt);
|
||||
}
|
||||
|
||||
void test_default_implicit_construction ( X const&, optional<X> opt )
|
||||
{
|
||||
BOOST_CHECK(!opt);
|
||||
BOOST_TEST(!opt);
|
||||
}
|
||||
|
||||
//
|
||||
@ -188,65 +188,65 @@ void test_conditional_ctor_and_get_valur_or ( T const* )
|
||||
check_value(o1,a,z);
|
||||
|
||||
T b = def0.get_value_or(z);
|
||||
BOOST_CHECK( b == z ) ;
|
||||
BOOST_TEST( b == z ) ;
|
||||
|
||||
b = get_optional_value_or(def0,z);
|
||||
BOOST_CHECK( b == z ) ;
|
||||
BOOST_TEST( b == z ) ;
|
||||
|
||||
b = o0.get_value_or(z);
|
||||
BOOST_CHECK( b == a ) ;
|
||||
BOOST_TEST( b == a ) ;
|
||||
|
||||
b = get_optional_value_or(o0,z);
|
||||
BOOST_CHECK( b == a ) ;
|
||||
BOOST_TEST( b == a ) ;
|
||||
|
||||
|
||||
T const& crz = z ;
|
||||
T& rz = z ;
|
||||
|
||||
T const& crzz = def0.get_value_or(crz);
|
||||
BOOST_CHECK( crzz == crz ) ;
|
||||
BOOST_TEST( crzz == crz ) ;
|
||||
|
||||
T& rzz = def0.get_value_or(rz);
|
||||
BOOST_CHECK( rzz == rz ) ;
|
||||
BOOST_TEST( rzz == rz ) ;
|
||||
|
||||
T const& crzzz = get_optional_value_or(cdef0,crz);
|
||||
BOOST_CHECK( crzzz == crz ) ;
|
||||
BOOST_TEST( crzzz == crz ) ;
|
||||
|
||||
T& rzzz = get_optional_value_or(def0,rz);
|
||||
BOOST_CHECK( rzzz == rz ) ;
|
||||
BOOST_TEST( rzzz == rz ) ;
|
||||
|
||||
T const& crb = o0.get_value_or(crz);
|
||||
BOOST_CHECK( crb == a ) ;
|
||||
BOOST_TEST( crb == a ) ;
|
||||
|
||||
T& rb = o0.get_value_or(rz);
|
||||
BOOST_CHECK( rb == b ) ;
|
||||
BOOST_TEST( rb == b ) ;
|
||||
|
||||
T const& crbb = get_optional_value_or(co0,crz);
|
||||
BOOST_CHECK( crbb == b ) ;
|
||||
BOOST_TEST( crbb == b ) ;
|
||||
|
||||
T const& crbbb = get_optional_value_or(o0,crz);
|
||||
BOOST_CHECK( crbbb == b ) ;
|
||||
BOOST_TEST( crbbb == b ) ;
|
||||
|
||||
T& rbb = get_optional_value_or(o0,rz);
|
||||
BOOST_CHECK( rbb == b ) ;
|
||||
BOOST_TEST( rbb == b ) ;
|
||||
|
||||
T& ra = a ;
|
||||
|
||||
optional<T&> defref(false,ra);
|
||||
BOOST_CHECK(!defref);
|
||||
BOOST_TEST(!defref);
|
||||
|
||||
optional<T&> ref(true,ra);
|
||||
BOOST_CHECK(!!ref);
|
||||
BOOST_TEST(!!ref);
|
||||
|
||||
a = T(432);
|
||||
|
||||
BOOST_CHECK( *ref == a ) ;
|
||||
BOOST_TEST( *ref == a ) ;
|
||||
|
||||
T& r1 = defref.get_value_or(z);
|
||||
BOOST_CHECK( r1 == z ) ;
|
||||
BOOST_TEST( r1 == z ) ;
|
||||
|
||||
T& r2 = ref.get_value_or(z);
|
||||
BOOST_CHECK( r2 == a ) ;
|
||||
BOOST_TEST( r2 == a ) ;
|
||||
}
|
||||
|
||||
//
|
||||
@ -262,18 +262,18 @@ void test_direct_value_manip( T const* )
|
||||
optional<T> const c_opt0(x) ;
|
||||
optional<T> opt0(x);
|
||||
|
||||
BOOST_CHECK( c_opt0.get().V() == x.V() ) ;
|
||||
BOOST_CHECK( opt0.get().V() == x.V() ) ;
|
||||
BOOST_TEST( c_opt0.get().V() == x.V() ) ;
|
||||
BOOST_TEST( opt0.get().V() == x.V() ) ;
|
||||
|
||||
BOOST_CHECK( c_opt0->V() == x.V() ) ;
|
||||
BOOST_CHECK( opt0->V() == x.V() ) ;
|
||||
BOOST_TEST( c_opt0->V() == x.V() ) ;
|
||||
BOOST_TEST( opt0->V() == x.V() ) ;
|
||||
|
||||
BOOST_CHECK( (*c_opt0).V() == x.V() ) ;
|
||||
BOOST_CHECK( (* opt0).V() == x.V() ) ;
|
||||
BOOST_TEST( (*c_opt0).V() == x.V() ) ;
|
||||
BOOST_TEST( (* opt0).V() == x.V() ) ;
|
||||
|
||||
T y(4);
|
||||
opt0 = y ;
|
||||
BOOST_CHECK( get(opt0).V() == y.V() ) ;
|
||||
BOOST_TEST( get(opt0).V() == y.V() ) ;
|
||||
}
|
||||
|
||||
//
|
||||
@ -295,7 +295,7 @@ void test_uninitialized_access( T const* )
|
||||
passed = true ;
|
||||
}
|
||||
catch (...) {}
|
||||
BOOST_CHECK(!passed);
|
||||
BOOST_TEST(!passed);
|
||||
|
||||
passed = false ;
|
||||
try
|
||||
@ -306,7 +306,7 @@ void test_uninitialized_access( T const* )
|
||||
passed = true ;
|
||||
}
|
||||
catch (...) {}
|
||||
BOOST_CHECK(!passed);
|
||||
BOOST_TEST(!passed);
|
||||
|
||||
passed = false ;
|
||||
try
|
||||
@ -318,7 +318,7 @@ void test_uninitialized_access( T const* )
|
||||
passed = true ;
|
||||
}
|
||||
catch (...) {}
|
||||
BOOST_CHECK(!passed);
|
||||
BOOST_TEST(!passed);
|
||||
|
||||
passed = false ;
|
||||
try
|
||||
@ -329,7 +329,7 @@ void test_uninitialized_access( T const* )
|
||||
passed = true ;
|
||||
}
|
||||
catch (...) {}
|
||||
BOOST_CHECK(!passed);
|
||||
BOOST_TEST(!passed);
|
||||
}
|
||||
|
||||
#if BOOST_WORKAROUND( BOOST_INTEL_CXX_VERSION, <= 700) // Intel C++ 7.0
|
||||
@ -374,7 +374,7 @@ void test_throwing_direct_init( T const* )
|
||||
}
|
||||
catch ( ... ){}
|
||||
|
||||
BOOST_CHECK(!passed);
|
||||
BOOST_TEST(!passed);
|
||||
check_is_not_pending_copy( ARG(T) );
|
||||
check_instance_count(count, ARG(T) );
|
||||
|
||||
@ -410,7 +410,7 @@ void test_throwing_val_assign_on_uninitialized( T const* )
|
||||
}
|
||||
catch ( ... ) {}
|
||||
|
||||
BOOST_CHECK(!passed);
|
||||
BOOST_TEST(!passed);
|
||||
|
||||
check_is_not_pending_copy( ARG(T) );
|
||||
check_instance_count(count, ARG(T) );
|
||||
@ -456,7 +456,7 @@ void test_throwing_val_assign_on_initialized( T const* )
|
||||
}
|
||||
catch ( ... ) {}
|
||||
|
||||
BOOST_CHECK(!passed);
|
||||
BOOST_TEST(!passed);
|
||||
|
||||
check_is_not_pending_assign( ARG(T) );
|
||||
check_instance_count(count, ARG(T) );
|
||||
@ -495,7 +495,7 @@ void test_throwing_copy_initialization( T const* )
|
||||
}
|
||||
catch ( ... ) {}
|
||||
|
||||
BOOST_CHECK(!passed);
|
||||
BOOST_TEST(!passed);
|
||||
|
||||
check_is_not_pending_copy( ARG(T) );
|
||||
check_instance_count(count, ARG(T) );
|
||||
@ -538,7 +538,7 @@ void test_throwing_assign_to_uninitialized( T const* )
|
||||
}
|
||||
catch ( ... ) {}
|
||||
|
||||
BOOST_CHECK(!passed);
|
||||
BOOST_TEST(!passed);
|
||||
|
||||
check_is_not_pending_copy( ARG(T) );
|
||||
check_instance_count(count, ARG(T) );
|
||||
@ -581,7 +581,7 @@ void test_throwing_assign_to_initialized( T const* )
|
||||
}
|
||||
catch ( ... ) {}
|
||||
|
||||
BOOST_CHECK(!passed);
|
||||
BOOST_TEST(!passed);
|
||||
|
||||
// opt0 was left uninitialized
|
||||
check_is_not_pending_assign( ARG(T) );
|
||||
@ -661,7 +661,7 @@ void test_throwing_swap( T const* )
|
||||
}
|
||||
catch ( ... ) {}
|
||||
|
||||
BOOST_CHECK(!passed);
|
||||
BOOST_TEST(!passed);
|
||||
|
||||
// optional's swap doesn't affect the initialized states of the arguments. Therefore,
|
||||
// the following must hold:
|
||||
@ -692,7 +692,7 @@ void test_throwing_swap( T const* )
|
||||
}
|
||||
catch ( ... ) {}
|
||||
|
||||
BOOST_CHECK(!passed);
|
||||
BOOST_TEST(!passed);
|
||||
|
||||
check_uninitialized(opt0);
|
||||
check_initialized(opt1);
|
||||
@ -720,69 +720,69 @@ void test_relops( T const* )
|
||||
optional<T> opt2(v2);
|
||||
|
||||
// Check identity
|
||||
BOOST_CHECK ( def0 == def0 ) ;
|
||||
BOOST_CHECK ( opt0 == opt0 ) ;
|
||||
BOOST_CHECK ( !(def0 != def0) ) ;
|
||||
BOOST_CHECK ( !(opt0 != opt0) ) ;
|
||||
BOOST_TEST ( def0 == def0 ) ;
|
||||
BOOST_TEST ( opt0 == opt0 ) ;
|
||||
BOOST_TEST ( !(def0 != def0) ) ;
|
||||
BOOST_TEST ( !(opt0 != opt0) ) ;
|
||||
|
||||
// Check when both are uininitalized.
|
||||
BOOST_CHECK ( def0 == def1 ) ; // both uninitialized compare equal
|
||||
BOOST_CHECK ( !(def0 < def1) ) ; // uninitialized is never less than uninitialized
|
||||
BOOST_CHECK ( !(def0 > def1) ) ; // uninitialized is never greater than uninitialized
|
||||
BOOST_CHECK ( !(def0 != def1) ) ;
|
||||
BOOST_CHECK ( def0 <= def1 ) ;
|
||||
BOOST_CHECK ( def0 >= def1 ) ;
|
||||
BOOST_TEST ( def0 == def1 ) ; // both uninitialized compare equal
|
||||
BOOST_TEST ( !(def0 < def1) ) ; // uninitialized is never less than uninitialized
|
||||
BOOST_TEST ( !(def0 > def1) ) ; // uninitialized is never greater than uninitialized
|
||||
BOOST_TEST ( !(def0 != def1) ) ;
|
||||
BOOST_TEST ( def0 <= def1 ) ;
|
||||
BOOST_TEST ( def0 >= def1 ) ;
|
||||
|
||||
// Check when only lhs is uninitialized.
|
||||
BOOST_CHECK ( def0 != opt0 ) ; // uninitialized is never equal to initialized
|
||||
BOOST_CHECK ( !(def0 == opt0) ) ;
|
||||
BOOST_CHECK ( def0 < opt0 ) ; // uninitialized is always less than initialized
|
||||
BOOST_CHECK ( !(def0 > opt0) ) ;
|
||||
BOOST_CHECK ( def0 <= opt0 ) ;
|
||||
BOOST_CHECK ( !(def0 >= opt0) ) ;
|
||||
BOOST_TEST ( def0 != opt0 ) ; // uninitialized is never equal to initialized
|
||||
BOOST_TEST ( !(def0 == opt0) ) ;
|
||||
BOOST_TEST ( def0 < opt0 ) ; // uninitialized is always less than initialized
|
||||
BOOST_TEST ( !(def0 > opt0) ) ;
|
||||
BOOST_TEST ( def0 <= opt0 ) ;
|
||||
BOOST_TEST ( !(def0 >= opt0) ) ;
|
||||
|
||||
// Check when only rhs is uninitialized.
|
||||
BOOST_CHECK ( opt0 != def0 ) ; // initialized is never equal to uninitialized
|
||||
BOOST_CHECK ( !(opt0 == def0) ) ;
|
||||
BOOST_CHECK ( !(opt0 < def0) ) ; // initialized is never less than uninitialized
|
||||
BOOST_CHECK ( opt0 > def0 ) ;
|
||||
BOOST_CHECK ( !(opt0 <= def0) ) ;
|
||||
BOOST_CHECK ( opt0 >= opt0 ) ;
|
||||
BOOST_TEST ( opt0 != def0 ) ; // initialized is never equal to uninitialized
|
||||
BOOST_TEST ( !(opt0 == def0) ) ;
|
||||
BOOST_TEST ( !(opt0 < def0) ) ; // initialized is never less than uninitialized
|
||||
BOOST_TEST ( opt0 > def0 ) ;
|
||||
BOOST_TEST ( !(opt0 <= def0) ) ;
|
||||
BOOST_TEST ( opt0 >= opt0 ) ;
|
||||
|
||||
// If both are initialized, values are compared
|
||||
BOOST_CHECK ( opt0 != opt1 ) ;
|
||||
BOOST_CHECK ( opt1 == opt2 ) ;
|
||||
BOOST_CHECK ( opt0 < opt1 ) ;
|
||||
BOOST_CHECK ( opt1 > opt0 ) ;
|
||||
BOOST_CHECK ( opt1 <= opt2 ) ;
|
||||
BOOST_CHECK ( opt1 >= opt0 ) ;
|
||||
BOOST_TEST ( opt0 != opt1 ) ;
|
||||
BOOST_TEST ( opt1 == opt2 ) ;
|
||||
BOOST_TEST ( opt0 < opt1 ) ;
|
||||
BOOST_TEST ( opt1 > opt0 ) ;
|
||||
BOOST_TEST ( opt1 <= opt2 ) ;
|
||||
BOOST_TEST ( opt1 >= opt0 ) ;
|
||||
|
||||
// Compare against a value directly
|
||||
BOOST_CHECK ( opt0 == v0 ) ;
|
||||
BOOST_CHECK ( opt0 != v1 ) ;
|
||||
BOOST_CHECK ( opt1 == v2 ) ;
|
||||
BOOST_CHECK ( opt0 < v1 ) ;
|
||||
BOOST_CHECK ( opt1 > v0 ) ;
|
||||
BOOST_CHECK ( opt1 <= v2 ) ;
|
||||
BOOST_CHECK ( opt1 >= v0 ) ;
|
||||
BOOST_CHECK ( v0 != opt1 ) ;
|
||||
BOOST_CHECK ( v1 == opt2 ) ;
|
||||
BOOST_CHECK ( v0 < opt1 ) ;
|
||||
BOOST_CHECK ( v1 > opt0 ) ;
|
||||
BOOST_CHECK ( v1 <= opt2 ) ;
|
||||
BOOST_CHECK ( v1 >= opt0 ) ;
|
||||
BOOST_CHECK ( def0 != v0 ) ;
|
||||
BOOST_CHECK ( !(def0 == v0) ) ;
|
||||
BOOST_CHECK ( def0 < v0 ) ;
|
||||
BOOST_CHECK ( !(def0 > v0) ) ;
|
||||
BOOST_CHECK ( def0 <= v0 ) ;
|
||||
BOOST_CHECK ( !(def0 >= v0) ) ;
|
||||
BOOST_CHECK ( v0 != def0 ) ;
|
||||
BOOST_CHECK ( !(v0 == def0) ) ;
|
||||
BOOST_CHECK ( !(v0 < def0) ) ;
|
||||
BOOST_CHECK ( v0 > def0 ) ;
|
||||
BOOST_CHECK ( !(v0 <= def0) ) ;
|
||||
BOOST_CHECK ( v0 >= opt0 ) ;
|
||||
BOOST_TEST ( opt0 == v0 ) ;
|
||||
BOOST_TEST ( opt0 != v1 ) ;
|
||||
BOOST_TEST ( opt1 == v2 ) ;
|
||||
BOOST_TEST ( opt0 < v1 ) ;
|
||||
BOOST_TEST ( opt1 > v0 ) ;
|
||||
BOOST_TEST ( opt1 <= v2 ) ;
|
||||
BOOST_TEST ( opt1 >= v0 ) ;
|
||||
BOOST_TEST ( v0 != opt1 ) ;
|
||||
BOOST_TEST ( v1 == opt2 ) ;
|
||||
BOOST_TEST ( v0 < opt1 ) ;
|
||||
BOOST_TEST ( v1 > opt0 ) ;
|
||||
BOOST_TEST ( v1 <= opt2 ) ;
|
||||
BOOST_TEST ( v1 >= opt0 ) ;
|
||||
BOOST_TEST ( def0 != v0 ) ;
|
||||
BOOST_TEST ( !(def0 == v0) ) ;
|
||||
BOOST_TEST ( def0 < v0 ) ;
|
||||
BOOST_TEST ( !(def0 > v0) ) ;
|
||||
BOOST_TEST ( def0 <= v0 ) ;
|
||||
BOOST_TEST ( !(def0 >= v0) ) ;
|
||||
BOOST_TEST ( v0 != def0 ) ;
|
||||
BOOST_TEST ( !(v0 == def0) ) ;
|
||||
BOOST_TEST ( !(v0 < def0) ) ;
|
||||
BOOST_TEST ( v0 > def0 ) ;
|
||||
BOOST_TEST ( !(v0 <= def0) ) ;
|
||||
BOOST_TEST ( v0 >= opt0 ) ;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
@ -796,16 +796,16 @@ void test_none( T const* )
|
||||
optional<T> def1(none) ;
|
||||
optional<T> non_def( T(1234) ) ;
|
||||
|
||||
BOOST_CHECK ( def0 == none ) ;
|
||||
BOOST_CHECK ( non_def != none ) ;
|
||||
BOOST_CHECK ( !def1 ) ;
|
||||
BOOST_CHECK ( !(non_def < none) ) ;
|
||||
BOOST_CHECK ( non_def > none ) ;
|
||||
BOOST_CHECK ( !(non_def <= none) ) ;
|
||||
BOOST_CHECK ( non_def >= none ) ;
|
||||
BOOST_TEST ( def0 == none ) ;
|
||||
BOOST_TEST ( non_def != none ) ;
|
||||
BOOST_TEST ( !def1 ) ;
|
||||
BOOST_TEST ( !(non_def < none) ) ;
|
||||
BOOST_TEST ( non_def > none ) ;
|
||||
BOOST_TEST ( !(non_def <= none) ) ;
|
||||
BOOST_TEST ( non_def >= none ) ;
|
||||
|
||||
non_def = none ;
|
||||
BOOST_CHECK ( !non_def ) ;
|
||||
BOOST_TEST ( !non_def ) ;
|
||||
|
||||
test_default_implicit_construction(T(1),none);
|
||||
}
|
||||
@ -820,12 +820,12 @@ void test_arrow( T const* )
|
||||
optional<T> oa(a) ;
|
||||
optional<T> const coa(a) ;
|
||||
|
||||
BOOST_CHECK ( coa->V() == 1234 ) ;
|
||||
BOOST_TEST ( coa->V() == 1234 ) ;
|
||||
|
||||
oa->V() = 4321 ;
|
||||
|
||||
BOOST_CHECK ( a.V() = 1234 ) ;
|
||||
BOOST_CHECK ( (*oa).V() = 4321 ) ;
|
||||
BOOST_TEST ( a.V() = 1234 ) ;
|
||||
BOOST_TEST ( (*oa).V() = 4321 ) ;
|
||||
}
|
||||
|
||||
void test_with_builtin_types()
|
||||
@ -869,7 +869,7 @@ void test_with_class_type()
|
||||
test_relops( ARG(X) ) ;
|
||||
test_none( ARG(X) ) ;
|
||||
test_arrow( ARG(X) ) ;
|
||||
BOOST_CHECK ( X::count == 0 ) ;
|
||||
BOOST_TEST ( X::count == 0 ) ;
|
||||
}
|
||||
|
||||
int eat ( bool ) { return 1 ; }
|
||||
@ -888,7 +888,7 @@ void test_no_implicit_conversions_impl( T const& )
|
||||
TRACE( std::endl << BOOST_CURRENT_FUNCTION );
|
||||
|
||||
optional<T> def ;
|
||||
BOOST_CHECK ( eat(def) == 0 ) ;
|
||||
BOOST_TEST ( eat(def) == 0 ) ;
|
||||
}
|
||||
|
||||
void test_no_implicit_conversions()
|
||||
@ -908,7 +908,7 @@ void test_no_implicit_conversions()
|
||||
|
||||
|
||||
// Test for support for classes with overridden operator&
|
||||
class CustomAddressOfClass
|
||||
class CustomAddressOfClass
|
||||
{
|
||||
int n;
|
||||
|
||||
@ -923,18 +923,18 @@ public:
|
||||
void test_custom_addressof_operator()
|
||||
{
|
||||
boost::optional< CustomAddressOfClass > o1(CustomAddressOfClass(10));
|
||||
BOOST_CHECK(!!o1);
|
||||
BOOST_CHECK(o1.get() == CustomAddressOfClass(10));
|
||||
BOOST_TEST(!!o1);
|
||||
BOOST_TEST(o1.get() == CustomAddressOfClass(10));
|
||||
|
||||
o1 = CustomAddressOfClass(20);
|
||||
BOOST_CHECK(!!o1);
|
||||
BOOST_CHECK(o1.get() == CustomAddressOfClass(20));
|
||||
BOOST_TEST(!!o1);
|
||||
BOOST_TEST(o1.get() == CustomAddressOfClass(20));
|
||||
|
||||
o1 = boost::none;
|
||||
BOOST_CHECK(!o1);
|
||||
BOOST_TEST(!o1);
|
||||
}
|
||||
|
||||
int test_main( int, char* [] )
|
||||
int main()
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -948,7 +948,7 @@ int test_main( int, char* [] )
|
||||
BOOST_ERROR("Unexpected Exception caught!");
|
||||
}
|
||||
|
||||
return 0;
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
|
@ -159,13 +159,13 @@ inline void set_throw_on_copy ( X const* x ) { X::throw_on_copy = true
|
||||
inline void set_throw_on_assign ( X const* x ) { X::throw_on_assign = true ; }
|
||||
inline void reset_throw_on_copy ( X const* x ) { X::throw_on_copy = false ; }
|
||||
inline void reset_throw_on_assign ( X const* x ) { X::throw_on_assign = false ; }
|
||||
inline void check_is_pending_copy ( X const* x ) { BOOST_CHECK( X::pending_copy ) ; }
|
||||
inline void check_is_pending_dtor ( X const* x ) { BOOST_CHECK( X::pending_dtor ) ; }
|
||||
inline void check_is_pending_assign ( X const* x ) { BOOST_CHECK( X::pending_assign ) ; }
|
||||
inline void check_is_not_pending_copy ( X const* x ) { BOOST_CHECK( !X::pending_copy ) ; }
|
||||
inline void check_is_not_pending_dtor ( X const* x ) { BOOST_CHECK( !X::pending_dtor ) ; }
|
||||
inline void check_is_not_pending_assign( X const* x ) { BOOST_CHECK( !X::pending_assign ) ; }
|
||||
inline void check_instance_count ( int c, X const* x ) { BOOST_CHECK( X::count == c ) ; }
|
||||
inline void check_is_pending_copy ( X const* x ) { BOOST_TEST( X::pending_copy ) ; }
|
||||
inline void check_is_pending_dtor ( X const* x ) { BOOST_TEST( X::pending_dtor ) ; }
|
||||
inline void check_is_pending_assign ( X const* x ) { BOOST_TEST( X::pending_assign ) ; }
|
||||
inline void check_is_not_pending_copy ( X const* x ) { BOOST_TEST( !X::pending_copy ) ; }
|
||||
inline void check_is_not_pending_dtor ( X const* x ) { BOOST_TEST( !X::pending_dtor ) ; }
|
||||
inline void check_is_not_pending_assign( X const* x ) { BOOST_TEST( !X::pending_assign ) ; }
|
||||
inline void check_instance_count ( int c, X const* x ) { BOOST_TEST( X::count == c ) ; }
|
||||
inline int get_instance_count ( X const* x ) { return X::count ; }
|
||||
|
||||
inline void set_pending_copy (...) {}
|
||||
@ -189,21 +189,21 @@ template<class T>
|
||||
inline void check_uninitialized_const ( optional<T> const& opt )
|
||||
{
|
||||
#ifndef BOOST_OPTIONAL_NO_NULL_COMPARE
|
||||
BOOST_CHECK( opt == 0 ) ;
|
||||
BOOST_TEST( opt == 0 ) ;
|
||||
#endif
|
||||
BOOST_CHECK( !opt ) ;
|
||||
BOOST_CHECK( !get_pointer(opt) ) ;
|
||||
BOOST_CHECK( !opt.get_ptr() ) ;
|
||||
BOOST_TEST( !opt ) ;
|
||||
BOOST_TEST( !get_pointer(opt) ) ;
|
||||
BOOST_TEST( !opt.get_ptr() ) ;
|
||||
}
|
||||
template<class T>
|
||||
inline void check_uninitialized ( optional<T>& opt )
|
||||
{
|
||||
#ifndef BOOST_OPTIONAL_NO_NULL_COMPARE
|
||||
BOOST_CHECK( opt == 0 ) ;
|
||||
BOOST_TEST( opt == 0 ) ;
|
||||
#endif
|
||||
BOOST_CHECK( !opt ) ;
|
||||
BOOST_CHECK( !get_pointer(opt) ) ;
|
||||
BOOST_CHECK( !opt.get_ptr() ) ;
|
||||
BOOST_TEST( !opt ) ;
|
||||
BOOST_TEST( !get_pointer(opt) ) ;
|
||||
BOOST_TEST( !opt.get_ptr() ) ;
|
||||
|
||||
check_uninitialized_const(opt);
|
||||
}
|
||||
@ -211,29 +211,29 @@ inline void check_uninitialized ( optional<T>& opt )
|
||||
template<class T>
|
||||
inline void check_initialized_const ( optional<T> const& opt )
|
||||
{
|
||||
BOOST_CHECK( opt ) ;
|
||||
BOOST_TEST( opt ) ;
|
||||
|
||||
#ifndef BOOST_OPTIONAL_NO_NULL_COMPARE
|
||||
BOOST_CHECK( opt != 0 ) ;
|
||||
BOOST_TEST( opt != 0 ) ;
|
||||
#endif
|
||||
|
||||
BOOST_CHECK ( !!opt ) ;
|
||||
BOOST_CHECK ( get_pointer(opt) ) ;
|
||||
BOOST_CHECK ( opt.get_ptr() ) ;
|
||||
BOOST_TEST ( !!opt ) ;
|
||||
BOOST_TEST ( get_pointer(opt) ) ;
|
||||
BOOST_TEST ( opt.get_ptr() ) ;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void check_initialized ( optional<T>& opt )
|
||||
{
|
||||
BOOST_CHECK( opt ) ;
|
||||
BOOST_TEST( opt ) ;
|
||||
|
||||
#ifndef BOOST_OPTIONAL_NO_NULL_COMPARE
|
||||
BOOST_CHECK( opt != 0 ) ;
|
||||
BOOST_TEST( opt != 0 ) ;
|
||||
#endif
|
||||
|
||||
BOOST_CHECK ( !!opt ) ;
|
||||
BOOST_CHECK ( get_pointer(opt) ) ;
|
||||
BOOST_CHECK ( opt.get_ptr() ) ;
|
||||
BOOST_TEST ( !!opt ) ;
|
||||
BOOST_TEST ( get_pointer(opt) ) ;
|
||||
BOOST_TEST ( opt.get_ptr() ) ;
|
||||
|
||||
check_initialized_const(opt);
|
||||
}
|
||||
@ -241,12 +241,12 @@ inline void check_initialized ( optional<T>& opt )
|
||||
template<class T>
|
||||
inline void check_value_const ( optional<T> const& opt, T const& v, T const& z )
|
||||
{
|
||||
BOOST_CHECK( *opt == v ) ;
|
||||
BOOST_CHECK( *opt != z ) ;
|
||||
BOOST_CHECK( opt.get() == v ) ;
|
||||
BOOST_CHECK( opt.get() != z ) ;
|
||||
BOOST_CHECK( (*(opt.operator->()) == v) ) ;
|
||||
BOOST_CHECK( *get_pointer(opt) == v ) ;
|
||||
BOOST_TEST( *opt == v ) ;
|
||||
BOOST_TEST( *opt != z ) ;
|
||||
BOOST_TEST( opt.get() == v ) ;
|
||||
BOOST_TEST( opt.get() != z ) ;
|
||||
BOOST_TEST( (*(opt.operator->()) == v) ) ;
|
||||
BOOST_TEST( *get_pointer(opt) == v ) ;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
@ -258,12 +258,12 @@ inline void check_value ( optional<T>& opt, T const& v, T const& z )
|
||||
reset_throw_on_copy( ARG(T) ) ;
|
||||
#endif
|
||||
|
||||
BOOST_CHECK( *opt == v ) ;
|
||||
BOOST_CHECK( *opt != z ) ;
|
||||
BOOST_CHECK( opt.get() == v ) ;
|
||||
BOOST_CHECK( opt.get() != z ) ;
|
||||
BOOST_CHECK( (*(opt.operator->()) == v) ) ;
|
||||
BOOST_CHECK( *get_pointer(opt) == v ) ;
|
||||
BOOST_TEST( *opt == v ) ;
|
||||
BOOST_TEST( *opt != z ) ;
|
||||
BOOST_TEST( opt.get() == v ) ;
|
||||
BOOST_TEST( opt.get() != z ) ;
|
||||
BOOST_TEST( (*(opt.operator->()) == v) ) ;
|
||||
BOOST_TEST( *get_pointer(opt) == v ) ;
|
||||
|
||||
check_value_const(opt,v,z);
|
||||
}
|
||||
|
@ -145,25 +145,62 @@ void test_clear_on_throw()
|
||||
|
||||
void test_no_assignment_on_emplacement()
|
||||
{
|
||||
optional<const std::string> os;
|
||||
optional<const std::string> os, ot;
|
||||
BOOST_TEST(!os);
|
||||
os.emplace("wow");
|
||||
BOOST_TEST(os);
|
||||
BOOST_TEST_EQ(*os, "wow");
|
||||
|
||||
BOOST_TEST(!ot);
|
||||
ot.emplace();
|
||||
BOOST_TEST(ot);
|
||||
BOOST_TEST_EQ(*ot, "");
|
||||
}
|
||||
|
||||
namespace no_rvalue_refs {
|
||||
class Guard
|
||||
{
|
||||
public:
|
||||
int which_ctor;
|
||||
Guard () : which_ctor(0) { }
|
||||
Guard (std::string const&) : which_ctor(5) { }
|
||||
Guard (std::string &) : which_ctor(6) { }
|
||||
private:
|
||||
Guard(Guard const&);
|
||||
void operator=(Guard const&);
|
||||
};
|
||||
|
||||
void test_emplace()
|
||||
{
|
||||
const std::string cs;
|
||||
std::string ms;
|
||||
optional<Guard> o;
|
||||
|
||||
o.emplace();
|
||||
BOOST_TEST(o);
|
||||
BOOST_TEST(0 == o->which_ctor);
|
||||
|
||||
o.emplace(cs);
|
||||
BOOST_TEST(o);
|
||||
BOOST_TEST(5 == o->which_ctor);
|
||||
|
||||
o.emplace(ms);
|
||||
BOOST_TEST(o);
|
||||
BOOST_TEST(6 == o->which_ctor);
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
#if (!defined BOOST_NO_CXX11_RVALUE_REFERENCES) && (!defined BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
test_emplace();
|
||||
test_emplace();
|
||||
#endif
|
||||
#if (!defined BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
test_no_moves_on_emplacement();
|
||||
test_no_moves_on_emplacement();
|
||||
#endif
|
||||
test_clear_on_throw();
|
||||
test_no_assignment_on_emplacement();
|
||||
|
||||
return boost::report_errors();
|
||||
test_clear_on_throw();
|
||||
test_no_assignment_on_emplacement();
|
||||
no_rvalue_refs::test_emplace();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
|
23
test/optional_test_fail_none_io_without_io.cpp
Normal file
23
test/optional_test_fail_none_io_without_io.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
// Copyright (C) 2015, Andrzej Krzemienski.
|
||||
//
|
||||
// Use, modification, and distribution is 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)
|
||||
//
|
||||
// See http://www.boost.org/lib/optional for documentation.
|
||||
//
|
||||
// You are welcome to contact the author at:
|
||||
// akrzemi1@gmail.com
|
||||
|
||||
#include <iostream>
|
||||
#include "boost/none.hpp"
|
||||
// but no boost/optional/optional_io.hpp
|
||||
|
||||
// THIS TEST SHOULD FAIL TO COMPILE
|
||||
// Unless one includes header boost/optional/optional_io.hpp, it should not be possible
|
||||
// to stream out boost::none.
|
||||
|
||||
void test_streaming_out_none()
|
||||
{
|
||||
std::cout << boost::none;
|
||||
}
|
@ -21,7 +21,7 @@ using boost::optional;
|
||||
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
#ifndef BOOST_NO_NOEXCEPT
|
||||
#ifndef BOOST_NO_CXX11_NOEXCEPT
|
||||
|
||||
// these 4 classes have different noexcept signatures in move operations
|
||||
struct NothrowBoth {
|
||||
@ -105,7 +105,7 @@ void test_noexcept_optional_with_operator() // compile-time test
|
||||
BOOST_STATIC_ASSERT(!BOOST_NOEXCEPT_EXPR( onx0 = ONx0() ));
|
||||
}
|
||||
|
||||
#endif // !defned BOOST_NO_NOEXCEPT
|
||||
#endif // !defned BOOST_NO_CXX11_NOEXCEPT
|
||||
#endif // !defined BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
int main()
|
||||
|
@ -15,6 +15,7 @@
|
||||
//
|
||||
|
||||
#include "boost/optional/optional.hpp"
|
||||
#include "boost/utility/in_place_factory.hpp"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
|
Reference in New Issue
Block a user