Uses intrusive is_convertible in MSVC compilers.
Removes some throw conditions in the documentation produced by the allocator copy constructor (as the standard requires no-throw guarantee for those).
This commit is contained in:
Ion Gaztañaga
2014-04-17 00:06:59 +02:00
parent 4da327f7b1
commit bffd6c036c
14 changed files with 74 additions and 80 deletions

View File

@@ -298,7 +298,7 @@ public:
//! @param count The number of values which will be contained in the container.
//!
//! @par Throws
//! If Value's default constructor throws.
//! If Value's value initialization throws.
//! @internal
//! @li If a throwing error handler is specified, throws when the capacity is exceeded. (not by default).
//! @endinternal
@@ -621,7 +621,7 @@ public:
//! @param count The number of elements which will be stored in the container.
//!
//! @par Throws
//! If Value's default constructor throws.
//! If Value's value initialization throws.
//! @internal
//! @li If a throwing error handler is specified, throws when the capacity is exceeded. (not by default).
//! @endinternal

View File

@@ -97,7 +97,7 @@ public:
//! @param count The number of values which will be contained in the container.
//!
//! @par Throws
//! If Value's default constructor throws.
//! If Value's value initialization throws.
//!
//! @par Complexity
//! Linear O(N).
@@ -317,7 +317,7 @@ public:
//! @param count The number of elements which will be stored in the container.
//!
//! @par Throws
//! If Value's default constructor throws.
//! If Value's value initialization throws.
//!
//! @par Complexity
//! Linear O(N).

View File

@@ -963,6 +963,7 @@ use [*Boost.Container]? There are several reasons for that:
* Fixed bugs:
* [@https://svn.boost.org/trac/boost/ticket/9338 #9338: ['"VS2005 compiler errors in swap() definition after including container/memory_util.hpp"]].
* [@https://svn.boost.org/trac/boost/ticket/9648 #9648: ['"string construction optimization - char_traits::copy could be used ..."]].
* [@https://svn.boost.org/trac/boost/ticket/9915 #9915: ['"Documentation issues regarding vector constructors and resize methods - value/default initialization"]].
[endsect]

View File

@@ -35,7 +35,7 @@ int main ()
l.emplace(l.begin(), 0);
assert(l.size() == 1);
//A new element will be built calling the default constructor
//A new element will be value initialized
l.emplace(l.begin());
assert(l.size() == 2);
return 0;

View File

@@ -335,32 +335,7 @@ class adaptive_pool
//!instance can be deallocated by another instance
friend bool operator!=(const adaptive_pool &, const adaptive_pool &) BOOST_CONTAINER_NOEXCEPT
{ return false; }
/*
//!Returns address of mutable object.
//!Never throws
pointer address(reference value) const
{ return pointer(boost::addressof(value)); }
//!Returns address of non mutable object.
//!Never throws
const_pointer address(const_reference value) const
{ return const_pointer(boost::addressof(value)); }
//!Default construct an object.
//!Throws if T's default constructor throws
void construct(const pointer &ptr)
{ new(ptr) value_type; }
//!Construct a copy of the passed object.
//!Throws if T's copy constructor throws
void construct(pointer ptr, const_reference t)
{ new(ptr) value_type(t); }
//!Destroys object. Throws if object's
//!destructor throws
void destroy(const pointer &ptr)
{ (void)ptr; BOOST_ASSERT(ptr); (*ptr).~value_type(); }
*/
private:
std::pair<pointer, bool> priv_allocation_command
(allocation_type command, std::size_t limit_size

View File

@@ -67,7 +67,7 @@ class allocator<void, Version, AllocationDisableMask>
//!Default constructor
//!Never throws
allocator()
allocator()
{}
//!Constructor from other allocator.

View File

@@ -541,8 +541,8 @@ class deque : protected deque_base<Allocator>
//! <b>Effects</b>: Constructs a deque that will use a copy of allocator a
//! and inserts n value initialized values.
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! throws or T's default or copy constructor throws.
//! <b>Throws</b>: If allocator_type's default constructor
//! throws or T's value initialization or copy constructor throws.
//!
//! <b>Complexity</b>: Linear to n.
explicit deque(size_type n)
@@ -556,8 +556,8 @@ class deque : protected deque_base<Allocator>
//! <b>Effects</b>: Constructs a deque that will use a copy of allocator a
//! and inserts n default initialized values.
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! throws or T's default or copy constructor throws.
//! <b>Throws</b>: If allocator_type's default constructor
//! throws or T's default initialization or copy constructor throws.
//!
//! <b>Complexity</b>: Linear to n.
//!
@@ -573,8 +573,8 @@ class deque : protected deque_base<Allocator>
//! <b>Effects</b>: Constructs a deque that will use a copy of allocator a
//! and inserts n copies of value.
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! throws or T's default or copy constructor throws.
//! <b>Throws</b>: If allocator_type's default constructor
//! throws or T's copy constructor throws.
//!
//! <b>Complexity</b>: Linear to n.
deque(size_type n, const value_type& value,
@@ -585,8 +585,8 @@ class deque : protected deque_base<Allocator>
//! <b>Effects</b>: Constructs a deque that will use a copy of allocator a
//! and inserts a copy of the range [first, last) in the deque.
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! throws or T's constructor taking an dereferenced InIt throws.
//! <b>Throws</b>: If allocator_type's default constructor
//! throws or T's constructor taking a dereferenced InIt throws.
//!
//! <b>Complexity</b>: Linear to the range [first, last).
template <class InIt>

View File

@@ -69,18 +69,32 @@ struct disable_if : public enable_if_c<!Cond::value, T> {};
template <bool B, class T = void>
struct disable_if_c : public enable_if_c<!B, T> {};
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
template <class T, class U>
struct is_convertible
{
static const bool value = __is_convertible_to(T, U);
};
#else
template <class T, class U>
class is_convertible
{
typedef char true_t;
class false_t { char dummy[2]; };
static true_t dispatch(U);
//use any_conversion as first parameter since in MSVC
//overaligned types can't go through ellipsis
static false_t dispatch(...);
static T trigger();
static true_t dispatch(U);
static T &trigger();
public:
enum { value = sizeof(dispatch(trigger())) == sizeof(true_t) };
static const bool value = sizeof(dispatch(trigger())) == sizeof(true_t);
};
#endif
template<
bool C
, typename T1

View File

@@ -220,7 +220,7 @@ class list
//! <b>Effects</b>: Constructs a list that will use a copy of allocator a
//! and inserts n copies of value.
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! <b>Throws</b>: If allocator_type's default constructor
//! throws or T's default or copy constructor throws.
//!
//! <b>Complexity</b>: Linear to n.
@@ -231,7 +231,7 @@ class list
//! <b>Effects</b>: Constructs a list that will use a copy of allocator a
//! and inserts n copies of value.
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! <b>Throws</b>: If allocator_type's default constructor
//! throws or T's default or copy constructor throws.
//!
//! <b>Complexity</b>: Linear to n.
@@ -243,7 +243,7 @@ class list
//!
//! <b>Postcondition</b>: x == *this.
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor throws.
//! <b>Throws</b>: If allocator_type's default constructor throws.
//!
//! <b>Complexity</b>: Linear to the elements x contains.
list(const list& x)
@@ -290,8 +290,8 @@ class list
//! <b>Effects</b>: Constructs a list that will use a copy of allocator a
//! and inserts a copy of the range [first, last) in the list.
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! throws or T's constructor taking an dereferenced InIt throws.
//! <b>Throws</b>: If allocator_type's default constructor
//! throws or T's constructor taking a dereferenced InIt throws.
//!
//! <b>Complexity</b>: Linear to the range [first, last).
template <class InpIt>

View File

@@ -252,7 +252,7 @@ class slist
//! <b>Effects</b>: Constructs a list that will use a copy of allocator a
//! and inserts n copies of value.
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! <b>Throws</b>: If allocator_type's default constructor
//! throws or T's default or copy constructor throws.
//!
//! <b>Complexity</b>: Linear to n.
@@ -263,8 +263,8 @@ class slist
//! <b>Effects</b>: Constructs a list that will use a copy of allocator a
//! and inserts a copy of the range [first, last) in the list.
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! throws or T's constructor taking an dereferenced InIt throws.
//! <b>Throws</b>: If allocator_type's default constructor
//! throws or T's constructor taking a dereferenced InIt throws.
//!
//! <b>Complexity</b>: Linear to the range [first, last).
template <class InpIt>
@@ -276,7 +276,7 @@ class slist
//!
//! <b>Postcondition</b>: x == *this.
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor throws.
//! <b>Throws</b>: If allocator_type's default constructor
//!
//! <b>Complexity</b>: Linear to the elements x contains.
slist(const slist& x)
@@ -296,7 +296,7 @@ class slist
//!
//! <b>Postcondition</b>: x == *this.
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor throws.
//! <b>Throws</b>: If allocator_type's default constructor
//!
//! <b>Complexity</b>: Linear to the elements x contains.
slist(const slist& x, const allocator_type &a)

View File

@@ -573,7 +573,7 @@ class stable_vector
//! <b>Effects</b>: Constructs a stable_vector that will use a copy of allocator a
//! and inserts n value initialized values.
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! <b>Throws</b>: If allocator_type's default constructor
//! throws or T's default or copy constructor throws.
//!
//! <b>Complexity</b>: Linear to n.
@@ -589,7 +589,7 @@ class stable_vector
//! <b>Effects</b>: Constructs a stable_vector that will use a copy of allocator a
//! and inserts n default initialized values.
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! <b>Throws</b>: If allocator_type's default constructor
//! throws or T's default or copy constructor throws.
//!
//! <b>Complexity</b>: Linear to n.
@@ -607,7 +607,7 @@ class stable_vector
//! <b>Effects</b>: Constructs a stable_vector that will use a copy of allocator a
//! and inserts n copies of value.
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! <b>Throws</b>: If allocator_type's default constructor
//! throws or T's default or copy constructor throws.
//!
//! <b>Complexity</b>: Linear to n.
@@ -623,8 +623,8 @@ class stable_vector
//! <b>Effects</b>: Constructs a stable_vector that will use a copy of allocator a
//! and inserts a copy of the range [first, last) in the stable_vector.
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! throws or T's constructor taking an dereferenced InIt throws.
//! <b>Throws</b>: If allocator_type's default constructor
//! throws or T's constructor taking a dereferenced InIt throws.
//!
//! <b>Complexity</b>: Linear to the range [first, last).
template <class InputIterator>
@@ -983,7 +983,7 @@ class stable_vector
//! <b>Effects</b>: Inserts or erases elements at the end such that
//! the size becomes n. New elements are value initialized.
//!
//! <b>Throws</b>: If memory allocation throws, or T's default constructor throws.
//! <b>Throws</b>: If memory allocation throws, or T's value initialization throws.
//!
//! <b>Complexity</b>: Linear to the difference between size() and new_size.
void resize(size_type n)
@@ -999,7 +999,7 @@ class stable_vector
//! <b>Effects</b>: Inserts or erases elements at the end such that
//! the size becomes n. New elements are default initialized.
//!
//! <b>Throws</b>: If memory allocation throws, or T's default constructor throws.
//! <b>Throws</b>: If memory allocation throws, or T's default initialization throws.
//!
//! <b>Complexity</b>: Linear to the difference between size() and new_size.
//!

View File

@@ -145,7 +145,7 @@ public:
//! @param count The number of values which will be contained in the container.
//!
//! @par Throws
//! If Value's default constructor throws.
//! If Value's value initialization throws.
//!
//! @par Complexity
//! Linear O(N).
@@ -155,12 +155,12 @@ public:
//! @pre <tt>count <= capacity()</tt>
//!
//! @brief Constructs a static_vector containing count value initialized values.
//! @brief Constructs a static_vector containing count default initialized values.
//!
//! @param count The number of values which will be contained in the container.
//!
//! @par Throws
//! If Value's default constructor throws.
//! If Value's default initialization throws.
//!
//! @par Complexity
//! Linear O(N).
@@ -383,7 +383,7 @@ public:
//! @param count The number of elements which will be stored in the container.
//!
//! @par Throws
//! If Value's default constructor throws.
//! If Value's value initialization throws.
//!
//! @par Complexity
//! Linear O(N).
@@ -397,7 +397,7 @@ public:
//! @param count The number of elements which will be stored in the container.
//!
//! @par Throws
//! If Value's default constructor throws.
//! If Value's default initialization throws.
//!
//! @par Complexity
//! Linear O(N).

View File

@@ -592,7 +592,7 @@ class basic_string
//!
//! <b>Postcondition</b>: x == *this.
//!
//! <b>Throws</b>: If allocator_type's default constructor throws.
//! <b>Throws</b>: If allocator_type's default constructor or allocation throws.
basic_string(const basic_string& s)
: base_t(allocator_traits_type::select_on_container_copy_construction(s.alloc()))
{
@@ -735,9 +735,13 @@ class basic_string
//! <b>Effects</b>: Move constructor. Moves mx's resources to *this.
//!
//! <b>Throws</b>: If allocator_type's copy constructor throws.
//! <b>Throws</b>: If allocator_traits_type::propagate_on_container_move_assignment
//! is true, when allocator_type's move assignment throws.
//! If allocator_traits_type::propagate_on_container_move_assignment
//! is false, when allocator_type's allocation throws.
//!
//! <b>Complexity</b>: Constant.
//! <b>Complexity</b>: Constant if allocator_traits_type::propagate_on_container_move_assignment.
//! is true, linear otherwise
basic_string& operator=(BOOST_RV_REF(basic_string) x) BOOST_CONTAINER_NOEXCEPT
{
if (&x != this){

View File

@@ -621,7 +621,7 @@ class vector
//! and inserts n value initialized values.
//!
//! <b>Throws</b>: If allocator_type's default constructor or allocation
//! throws or T's default constructor throws.
//! throws or T's value initialization throws.
//!
//! <b>Complexity</b>: Linear to n.
explicit vector(size_type n)
@@ -635,7 +635,7 @@ class vector
//! and inserts n default initialized values.
//!
//! <b>Throws</b>: If allocator_type's default constructor or allocation
//! throws or T's default constructor throws.
//! throws or T's default initialization throws.
//!
//! <b>Complexity</b>: Linear to n.
//!
@@ -679,7 +679,7 @@ class vector
//! and inserts a copy of the range [first, last) in the vector.
//!
//! <b>Throws</b>: If allocator_type's default constructor or allocation
//! throws or T's constructor taking an dereferenced InIt throws.
//! throws or T's constructor taking a dereferenced InIt throws.
//!
//! <b>Complexity</b>: Linear to the range [first, last).
template <class InIt>
@@ -691,7 +691,7 @@ class vector
//! and inserts a copy of the range [first, last) in the vector.
//!
//! <b>Throws</b>: If allocator_type's default constructor or allocation
//! throws or T's constructor taking an dereferenced InIt throws.
//! throws or T's constructor taking a dereferenced InIt throws.
//!
//! <b>Complexity</b>: Linear to the range [first, last).
template <class InIt>
@@ -1117,7 +1117,7 @@ class vector
//! <b>Effects</b>: Inserts or erases elements at the end such that
//! the size becomes n. New elements are value initialized.
//!
//! <b>Throws</b>: If memory allocation throws, or T's constructor throws.
//! <b>Throws</b>: If memory allocation throws, or T's copy/move or value initialization throws.
//!
//! <b>Complexity</b>: Linear to the difference between size() and new_size.
void resize(size_type new_size)
@@ -1126,7 +1126,7 @@ class vector
//! <b>Effects</b>: Inserts or erases elements at the end such that
//! the size becomes n. New elements are value initialized.
//!
//! <b>Throws</b>: If memory allocation throws, or T's constructor throws.
//! <b>Throws</b>: If memory allocation throws, or T's copy/move or default initialization throws.
//!
//! <b>Complexity</b>: Linear to the difference between size() and new_size.
//!
@@ -1137,7 +1137,7 @@ class vector
//! <b>Effects</b>: Inserts or erases elements at the end such that
//! the size becomes n. New elements are copy constructed from x.
//!
//! <b>Throws</b>: If memory allocation throws, or T's copy constructor throws.
//! <b>Throws</b>: If memory allocation throws, or T's copy/move constructor throws.
//!
//! <b>Complexity</b>: Linear to the difference between size() and new_size.
void resize(size_type new_size, const T& x)
@@ -1303,7 +1303,7 @@ class vector
//! std::forward<Args>(args)... in the end of the vector.
//!
//! <b>Throws</b>: If memory allocation throws or the in-place constructor throws or
//! T's move constructor throws.
//! T's copy/move constructor throws.
//!
//! <b>Complexity</b>: Amortized constant time.
template<class ...Args>
@@ -1328,7 +1328,7 @@ class vector
//! std::forward<Args>(args)... before position
//!
//! <b>Throws</b>: If memory allocation throws or the in-place constructor throws or
//! T's move constructor/assignment throws.
//! T's copy/move constructor/assignment throws.
//!
//! <b>Complexity</b>: If position is end(), amortized constant time
//! Linear time otherwise.
@@ -1389,10 +1389,10 @@ class vector
void push_back(const T &x);
//! <b>Effects</b>: Constructs a new element in the end of the vector
//! and moves the resources of mx to this new element.
//! and moves the resources of x to this new element.
//!
//! <b>Throws</b>: If memory allocation throws or
//! T's move constructor throws.
//! T's copy/move constructor throws.
//!
//! <b>Complexity</b>: Amortized constant time.
void push_back(T &&x);
@@ -1430,7 +1430,7 @@ class vector
//!
//! <b>Returns</b>: an iterator to the first inserted element or p if n is 0.
//!
//! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
//! <b>Throws</b>: If memory allocation throws or T's copy/move constructor throws.
//!
//! <b>Complexity</b>: Linear to n.
iterator insert(const_iterator p, size_type n, const T& x)
@@ -1550,7 +1550,7 @@ class vector
//! <b>Effects</b>: Swaps the contents of *this and x.
//!
//! <b>Throws</b>: If T's move constructor throws.
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Linear
//!