flat_set and flat_map's move constructors should be "noexcept" |
|||
Issue description
We want this so they can be efficiently stored in vectors using move semantics.
Attempting to add "noexcept" to the underlying flat_tree move constructor results in a Clang error on Mac and iOS:
In file included from ../../base/containers/flat_tree_unittest.cc:5:
../../base/containers/flat_tree.h:308:21: error: exception specification of 'vector' uses itself
underlying_type body_;
^
../../base/containers/flat_tree.h:308:21: note: in instantiation of exception specification for 'vector' requested here
../../buildtools/third_party/libc++/trunk/include/type_traits:3507:41: note: in instantiation of template class 'std::__1::is_constructible<std::__1::allocator<base::MoveOnlyInt>, std::__1::allocator<base::MoveOnlyInt> &&>' requested here
: __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, is_reference<_Tp>::value, _Tp, _Args...>
^
../../buildtools/third_party/libc++/trunk/include/type_traits:3658:14: note: in instantiation of template class 'std::__1::is_nothrow_constructible<std::__1::allocator<base::MoveOnlyInt>, std::__1::allocator<base::MoveOnlyInt> &&>' requested here
: public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type>
^
../../buildtools/third_party/libc++/trunk/include/vector:559:20: note: in instantiation of template class 'std::__1::is_nothrow_move_constructible<std::__1::allocator<base::MoveOnlyInt> >' requested here
_NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
^
../../base/containers/flat_tree.h:308:21: note: in instantiation of exception specification for 'vector' requested here
underlying_type body_;
^
../../base/containers/flat_tree_unittest.cc:307:16: note: in instantiation of member function 'base::internal::flat_tree<base::MoveOnlyInt, base::MoveOnlyInt, base::internal::GetKeyFromValueIdentity<base::MoveOnlyInt>, std::__1::less<base::MoveOnlyInt> >::flat_tree' requested here
MoveOnlyTree moved(std::move(original));
^
../../base/containers/flat_tree.h:338:53: note: implicit move constructor for 'base::internal::flat_tree<base::MoveOnlyInt, base::MoveOnlyInt, base::internal::GetKeyFromValueIdentity<base::MoveOnlyInt>, std::__1::less<base::MoveOnlyInt> >' first required here
flat_tree<Key, Value, GetKeyFromValue, KeyCompare>::flat_tree(
,
Mar 28 2018
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue. Sorry for the inconvenience if the bug really should have been left as Available. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Mar 28 2018
We're starting to use noexpect elsewhere, like Optional. Is this possible now?
,
Mar 28 2018
@danakj - does it work for optional? There were compilation issues. I'll try to create a patch.
,
Mar 28 2018
Out of curiosity - did you measure any impact with noexcept optional?
,
Mar 28 2018
No, we're trying to match the Optional spec there, didn't measure. Though also the google style guide now asks for noexcept on move constructors.
,
Mar 28 2018
@danakj - Oh, OK. I have some techincal issues on my behave, I cannot create a patch at the moment, sorry about that. |
|||
►
Sign in to add a comment |
|||
Comment 1 by brettw@chromium.org
, Mar 22 2017