Closed Lastique closed 5 years ago
Thanks for the patch. Commit 5ec7aa7 cherry-picked to develop. Investigating why continuous integration fails with the noexcept specificcation.
Reviewing the patch, some comments:
Cpp17Allocator requirements require noexcept for allocator move and copy constructors. This means that looking for dtl::is_nothrow_move_constructible
I'm unsure about marking some constructors conditionally noexcept (like the variadic constructor). It complicates code a lot and I don't think performance would improve. Not sure also if the variadic constructor is needed at all, I think it is not used, I will review the use cases.
Cpp17Allocator requirements require noexcept for allocator move and copy constructors. This means that looking for dtl::is_nothrow_move_constructible
::value and similar is redundant.
I didn't know allocator copy and move are required to be noexcept
. Not sure if every allocator in the wild follows this requirement, though, so I tend to prefer the traits. But I can change to BOOST_NOEXCEPT
no problem, if you want me to.
I'm unsure about marking some constructors conditionally noexcept (like the variadic constructor).
I'd like the constructors to be as transparent as possible.
Also, I seem to remember that at least some compilers prefer the templated constructors to non-templated ones like copy constructors in some cases. I think, it was when you construct a copy from a non-const allocator variable, but maybe there were other cases. For this reason, the templated constructor should have the same effect, including noexcept
specification, as the non-templated one.
I fixed a typo in the macro and rebased to the current develop. This should fix C++03 tests.
Thanks. All other containers assume allocator copy/move don't throw, so I've modified your patch to inconditionally make some operations noexcept. The variadic constructor was not needed at all so I've removed it, smalLvector_allocator is an internal class so no one should notice this.
small_vector_base
forward-declaration tocontainer_fwd.hpp
. This is useful if the user only wants to usesmall_vector_base
in its interface headers.small_vector
default constructornoexcept
specification.The default constructor used to incorrectly apply
is_nothrow_default_constructible
trait to the template argument of thesmall_vector
class template, which isvoid
by default. The fix is to apply the trait to the actual allocator type.Next is the fix for
noexcept
specifications of thesmall_vector_allocator
class members, including the default constructor, which was previously not declared and a non-noexcept
initializing constructor was used in its stead. The fix is to explicitly specify the default constructor with a propernoexcept
specification. While at it, other constructors and assignment operators were also fixed with propernoexcept
specifications.As a result,
small_vector
default constructornoexcept
specification now properly reflects whether the default constructor of the allocator isnoexcept
. This is useful if user's class hassmall_vector
members and attempts to request anoexcept
defaulted default constructor.