diff --git a/bench/detail/varray.hpp b/bench/detail/varray.hpp index eb63470..861e27b 100644 --- a/bench/detail/varray.hpp +++ b/bench/detail/varray.hpp @@ -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 diff --git a/bench/varray.hpp b/bench/varray.hpp index 8022b9a..4e72039 100644 --- a/bench/varray.hpp +++ b/bench/varray.hpp @@ -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). diff --git a/doc/container.qbk b/doc/container.qbk index cb6eac0..0ecd987 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -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] diff --git a/example/doc_emplace.cpp b/example/doc_emplace.cpp index 76b5939..2fe4aa0 100644 --- a/example/doc_emplace.cpp +++ b/example/doc_emplace.cpp @@ -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; diff --git a/include/boost/container/adaptive_pool.hpp b/include/boost/container/adaptive_pool.hpp index c176547..a1209f9 100644 --- a/include/boost/container/adaptive_pool.hpp +++ b/include/boost/container/adaptive_pool.hpp @@ -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 priv_allocation_command (allocation_type command, std::size_t limit_size diff --git a/include/boost/container/allocator.hpp b/include/boost/container/allocator.hpp index af46532..2b36b5e 100644 --- a/include/boost/container/allocator.hpp +++ b/include/boost/container/allocator.hpp @@ -67,7 +67,7 @@ class allocator //!Default constructor //!Never throws - allocator() + allocator() {} //!Constructor from other allocator. diff --git a/include/boost/container/deque.hpp b/include/boost/container/deque.hpp index 4fd2e7c..479a9c0 100644 --- a/include/boost/container/deque.hpp +++ b/include/boost/container/deque.hpp @@ -541,8 +541,8 @@ class deque : protected deque_base //! Effects: Constructs a deque that will use a copy of allocator a //! and inserts n value initialized values. //! - //! Throws: If allocator_type's default constructor or copy constructor - //! throws or T's default or copy constructor throws. + //! Throws: If allocator_type's default constructor + //! throws or T's value initialization or copy constructor throws. //! //! Complexity: Linear to n. explicit deque(size_type n) @@ -556,8 +556,8 @@ class deque : protected deque_base //! Effects: Constructs a deque that will use a copy of allocator a //! and inserts n default initialized values. //! - //! Throws: If allocator_type's default constructor or copy constructor - //! throws or T's default or copy constructor throws. + //! Throws: If allocator_type's default constructor + //! throws or T's default initialization or copy constructor throws. //! //! Complexity: Linear to n. //! @@ -573,8 +573,8 @@ class deque : protected deque_base //! Effects: Constructs a deque that will use a copy of allocator a //! and inserts n copies of value. //! - //! Throws: If allocator_type's default constructor or copy constructor - //! throws or T's default or copy constructor throws. + //! Throws: If allocator_type's default constructor + //! throws or T's copy constructor throws. //! //! Complexity: Linear to n. deque(size_type n, const value_type& value, @@ -585,8 +585,8 @@ class deque : protected deque_base //! Effects: Constructs a deque that will use a copy of allocator a //! and inserts a copy of the range [first, last) in the deque. //! - //! Throws: If allocator_type's default constructor or copy constructor - //! throws or T's constructor taking an dereferenced InIt throws. + //! Throws: If allocator_type's default constructor + //! throws or T's constructor taking a dereferenced InIt throws. //! //! Complexity: Linear to the range [first, last). template diff --git a/include/boost/container/detail/mpl.hpp b/include/boost/container/detail/mpl.hpp index 941e5ee..fc1a8a6 100644 --- a/include/boost/container/detail/mpl.hpp +++ b/include/boost/container/detail/mpl.hpp @@ -69,18 +69,32 @@ struct disable_if : public enable_if_c {}; template struct disable_if_c : public enable_if_c {}; +#if defined(_MSC_VER) && (_MSC_VER >= 1400) + +template +struct is_convertible +{ + static const bool value = __is_convertible_to(T, U); +}; + +#else + template 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 diff --git a/include/boost/container/list.hpp b/include/boost/container/list.hpp index 479c49a..079526b 100644 --- a/include/boost/container/list.hpp +++ b/include/boost/container/list.hpp @@ -220,7 +220,7 @@ class list //! Effects: Constructs a list that will use a copy of allocator a //! and inserts n copies of value. //! - //! Throws: If allocator_type's default constructor or copy constructor + //! Throws: If allocator_type's default constructor //! throws or T's default or copy constructor throws. //! //! Complexity: Linear to n. @@ -231,7 +231,7 @@ class list //! Effects: Constructs a list that will use a copy of allocator a //! and inserts n copies of value. //! - //! Throws: If allocator_type's default constructor or copy constructor + //! Throws: If allocator_type's default constructor //! throws or T's default or copy constructor throws. //! //! Complexity: Linear to n. @@ -243,7 +243,7 @@ class list //! //! Postcondition: x == *this. //! - //! Throws: If allocator_type's default constructor or copy constructor throws. + //! Throws: If allocator_type's default constructor throws. //! //! Complexity: Linear to the elements x contains. list(const list& x) @@ -290,8 +290,8 @@ class list //! Effects: Constructs a list that will use a copy of allocator a //! and inserts a copy of the range [first, last) in the list. //! - //! Throws: If allocator_type's default constructor or copy constructor - //! throws or T's constructor taking an dereferenced InIt throws. + //! Throws: If allocator_type's default constructor + //! throws or T's constructor taking a dereferenced InIt throws. //! //! Complexity: Linear to the range [first, last). template diff --git a/include/boost/container/slist.hpp b/include/boost/container/slist.hpp index eede912..81d8c53 100644 --- a/include/boost/container/slist.hpp +++ b/include/boost/container/slist.hpp @@ -252,7 +252,7 @@ class slist //! Effects: Constructs a list that will use a copy of allocator a //! and inserts n copies of value. //! - //! Throws: If allocator_type's default constructor or copy constructor + //! Throws: If allocator_type's default constructor //! throws or T's default or copy constructor throws. //! //! Complexity: Linear to n. @@ -263,8 +263,8 @@ class slist //! Effects: Constructs a list that will use a copy of allocator a //! and inserts a copy of the range [first, last) in the list. //! - //! Throws: If allocator_type's default constructor or copy constructor - //! throws or T's constructor taking an dereferenced InIt throws. + //! Throws: If allocator_type's default constructor + //! throws or T's constructor taking a dereferenced InIt throws. //! //! Complexity: Linear to the range [first, last). template @@ -276,7 +276,7 @@ class slist //! //! Postcondition: x == *this. //! - //! Throws: If allocator_type's default constructor or copy constructor throws. + //! Throws: If allocator_type's default constructor //! //! Complexity: Linear to the elements x contains. slist(const slist& x) @@ -296,7 +296,7 @@ class slist //! //! Postcondition: x == *this. //! - //! Throws: If allocator_type's default constructor or copy constructor throws. + //! Throws: If allocator_type's default constructor //! //! Complexity: Linear to the elements x contains. slist(const slist& x, const allocator_type &a) diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp index aef7bbc..950f288 100644 --- a/include/boost/container/stable_vector.hpp +++ b/include/boost/container/stable_vector.hpp @@ -573,7 +573,7 @@ class stable_vector //! Effects: Constructs a stable_vector that will use a copy of allocator a //! and inserts n value initialized values. //! - //! Throws: If allocator_type's default constructor or copy constructor + //! Throws: If allocator_type's default constructor //! throws or T's default or copy constructor throws. //! //! Complexity: Linear to n. @@ -589,7 +589,7 @@ class stable_vector //! Effects: Constructs a stable_vector that will use a copy of allocator a //! and inserts n default initialized values. //! - //! Throws: If allocator_type's default constructor or copy constructor + //! Throws: If allocator_type's default constructor //! throws or T's default or copy constructor throws. //! //! Complexity: Linear to n. @@ -607,7 +607,7 @@ class stable_vector //! Effects: Constructs a stable_vector that will use a copy of allocator a //! and inserts n copies of value. //! - //! Throws: If allocator_type's default constructor or copy constructor + //! Throws: If allocator_type's default constructor //! throws or T's default or copy constructor throws. //! //! Complexity: Linear to n. @@ -623,8 +623,8 @@ class stable_vector //! Effects: 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. //! - //! Throws: If allocator_type's default constructor or copy constructor - //! throws or T's constructor taking an dereferenced InIt throws. + //! Throws: If allocator_type's default constructor + //! throws or T's constructor taking a dereferenced InIt throws. //! //! Complexity: Linear to the range [first, last). template @@ -983,7 +983,7 @@ class stable_vector //! Effects: Inserts or erases elements at the end such that //! the size becomes n. New elements are value initialized. //! - //! Throws: If memory allocation throws, or T's default constructor throws. + //! Throws: If memory allocation throws, or T's value initialization throws. //! //! Complexity: Linear to the difference between size() and new_size. void resize(size_type n) @@ -999,7 +999,7 @@ class stable_vector //! Effects: Inserts or erases elements at the end such that //! the size becomes n. New elements are default initialized. //! - //! Throws: If memory allocation throws, or T's default constructor throws. + //! Throws: If memory allocation throws, or T's default initialization throws. //! //! Complexity: Linear to the difference between size() and new_size. //! diff --git a/include/boost/container/static_vector.hpp b/include/boost/container/static_vector.hpp index 19e27f5..583e7f5 100644 --- a/include/boost/container/static_vector.hpp +++ b/include/boost/container/static_vector.hpp @@ -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 count <= capacity() //! - //! @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). diff --git a/include/boost/container/string.hpp b/include/boost/container/string.hpp index 95187ee..67cbc38 100644 --- a/include/boost/container/string.hpp +++ b/include/boost/container/string.hpp @@ -592,7 +592,7 @@ class basic_string //! //! Postcondition: x == *this. //! - //! Throws: If allocator_type's default constructor throws. + //! Throws: 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 //! Effects: Move constructor. Moves mx's resources to *this. //! - //! Throws: If allocator_type's copy constructor throws. + //! Throws: 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. //! - //! Complexity: Constant. + //! Complexity: 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){ diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp index e706ac9..2792bff 100644 --- a/include/boost/container/vector.hpp +++ b/include/boost/container/vector.hpp @@ -621,7 +621,7 @@ class vector //! and inserts n value initialized values. //! //! Throws: If allocator_type's default constructor or allocation - //! throws or T's default constructor throws. + //! throws or T's value initialization throws. //! //! Complexity: Linear to n. explicit vector(size_type n) @@ -635,7 +635,7 @@ class vector //! and inserts n default initialized values. //! //! Throws: If allocator_type's default constructor or allocation - //! throws or T's default constructor throws. + //! throws or T's default initialization throws. //! //! Complexity: Linear to n. //! @@ -679,7 +679,7 @@ class vector //! and inserts a copy of the range [first, last) in the vector. //! //! Throws: 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. //! //! Complexity: Linear to the range [first, last). template @@ -691,7 +691,7 @@ class vector //! and inserts a copy of the range [first, last) in the vector. //! //! Throws: 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. //! //! Complexity: Linear to the range [first, last). template @@ -1117,7 +1117,7 @@ class vector //! Effects: Inserts or erases elements at the end such that //! the size becomes n. New elements are value initialized. //! - //! Throws: If memory allocation throws, or T's constructor throws. + //! Throws: If memory allocation throws, or T's copy/move or value initialization throws. //! //! Complexity: Linear to the difference between size() and new_size. void resize(size_type new_size) @@ -1126,7 +1126,7 @@ class vector //! Effects: Inserts or erases elements at the end such that //! the size becomes n. New elements are value initialized. //! - //! Throws: If memory allocation throws, or T's constructor throws. + //! Throws: If memory allocation throws, or T's copy/move or default initialization throws. //! //! Complexity: Linear to the difference between size() and new_size. //! @@ -1137,7 +1137,7 @@ class vector //! Effects: Inserts or erases elements at the end such that //! the size becomes n. New elements are copy constructed from x. //! - //! Throws: If memory allocation throws, or T's copy constructor throws. + //! Throws: If memory allocation throws, or T's copy/move constructor throws. //! //! Complexity: 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)... in the end of the vector. //! //! Throws: If memory allocation throws or the in-place constructor throws or - //! T's move constructor throws. + //! T's copy/move constructor throws. //! //! Complexity: Amortized constant time. template @@ -1328,7 +1328,7 @@ class vector //! std::forward(args)... before position //! //! Throws: If memory allocation throws or the in-place constructor throws or - //! T's move constructor/assignment throws. + //! T's copy/move constructor/assignment throws. //! //! Complexity: If position is end(), amortized constant time //! Linear time otherwise. @@ -1389,10 +1389,10 @@ class vector void push_back(const T &x); //! Effects: 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. //! //! Throws: If memory allocation throws or - //! T's move constructor throws. + //! T's copy/move constructor throws. //! //! Complexity: Amortized constant time. void push_back(T &&x); @@ -1430,7 +1430,7 @@ class vector //! //! Returns: an iterator to the first inserted element or p if n is 0. //! - //! Throws: If memory allocation throws or T's copy constructor throws. + //! Throws: If memory allocation throws or T's copy/move constructor throws. //! //! Complexity: Linear to n. iterator insert(const_iterator p, size_type n, const T& x) @@ -1550,7 +1550,7 @@ class vector //! Effects: Swaps the contents of *this and x. //! - //! Throws: If T's move constructor throws. + //! Throws: Nothing. //! //! Complexity: Linear //!