diff --git a/sprout/algorithm/copy.hpp b/sprout/algorithm/copy.hpp index 34141412..eb158687 100644 --- a/sprout/algorithm/copy.hpp +++ b/sprout/algorithm/copy.hpp @@ -9,6 +9,43 @@ #define SPROUT_ALGORITHM_COPY_HPP #include +#include +#include +#include +#include + +namespace sprout { + // + // 25.3.1 Copy + // + template< + typename InputIterator, typename OutputIterator, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + copy(InputIterator first, InputIterator last, OutputIterator result) { + while (first != last) { + *result++ = *first++; + } + return result; + } + + template< + typename InputIterator, typename Result, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type + copy(InputIterator first, InputIterator last, Result const& result) { + return sprout::fixed::copy(first, last, result); + } + + template + inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type + copy(InputIterator first, InputIterator last) { + return sprout::fixed::copy(first, last); + } +} // namespace sprout + #include #include diff --git a/sprout/algorithm/copy_backward.hpp b/sprout/algorithm/copy_backward.hpp index dcedeb4c..c2ce8a6f 100644 --- a/sprout/algorithm/copy_backward.hpp +++ b/sprout/algorithm/copy_backward.hpp @@ -9,6 +9,43 @@ #define SPROUT_ALGORITHM_COPY_BACKWARD_HPP #include +#include +#include +#include +#include + +namespace sprout { + // + // 25.3.1 Copy + // + template< + typename BidirectionalIterator1, typename BidirectionalIterator2, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR BidirectionalIterator2 + copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, BidirectionalIterator2 result) { + while (first != last) { + *--result = *--first; + } + return result; + } + + template< + typename BidirectionalIterator, typename Result, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type + copy_backward(BidirectionalIterator first, BidirectionalIterator last, Result const& result) { + return sprout::fixed::copy_backward(first, last, result); + } + + template + inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type + copy_backward(BidirectionalIterator first, BidirectionalIterator last) { + return sprout::fixed::copy_backward(first, last); + } +} // namespace sprout + #include #include diff --git a/sprout/algorithm/copy_if.hpp b/sprout/algorithm/copy_if.hpp index 2cdf7af6..b5755da9 100644 --- a/sprout/algorithm/copy_if.hpp +++ b/sprout/algorithm/copy_if.hpp @@ -9,6 +9,45 @@ #define SPROUT_ALGORITHM_COPY_IF_HPP #include +#include +#include +#include +#include + +namespace sprout { + // + // 25.3.1 Copy + // + template< + typename InputIterator, typename OutputIterator, typename Predicate, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred) { + for (; first != last; ++first) { + if (pred(*first)) { + *result++ = *first; + } + } + return result; + } + + template< + typename InputIterator, typename Result, typename Predicate, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type + copy_if(InputIterator first, InputIterator last, Result const& result, Predicate pred) { + return sprout::fixed::copy_if(first, last, result, pred); + } + + template + inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type + copy_if(InputIterator first, InputIterator last, Predicate pred) { + return sprout::fixed::copy_if(first, last, pred); + } +} // namespace sprout + #include #include diff --git a/sprout/algorithm/copy_n.hpp b/sprout/algorithm/copy_n.hpp index 1661bd79..86c415e8 100644 --- a/sprout/algorithm/copy_n.hpp +++ b/sprout/algorithm/copy_n.hpp @@ -9,6 +9,43 @@ #define SPROUT_ALGORITHM_COPY_N_HPP #include +#include +#include +#include +#include + +namespace sprout { + // + // 25.3.1 Copy + // + template< + typename InputIterator, typename Size, typename OutputIterator, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + copy_n(InputIterator first, Size n, OutputIterator result) { + for (Size i = 0; i < n; ++i) { + *result++ = *first++; + } + return result; + } + + template< + typename InputIterator, typename Size, typename Result, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type + copy_n(InputIterator first, Size n, Result const& result) { + return sprout::fixed::copy_n(first, n, result); + } + + template + inline SPROUT_CONSTEXPR typename sprout::fixed::result_of::algorithm::type + copy_n(InputIterator first, Size n) { + return sprout::fixed::copy_n(first, n); + } +} // namespace sprout + #include #include diff --git a/sprout/algorithm/fixed/copy.hpp b/sprout/algorithm/fixed/copy.hpp index 6f257c30..8045c483 100644 --- a/sprout/algorithm/fixed/copy.hpp +++ b/sprout/algorithm/fixed/copy.hpp @@ -134,8 +134,6 @@ namespace sprout { return sprout::fixed::copy(first, last, sprout::pit()); } } // namespace fixed - - using sprout::fixed::copy; } // namespace sprout #endif // #ifndef SPROUT_ALGORITHM_FIXED_COPY_HPP diff --git a/sprout/algorithm/fixed/copy_backward.hpp b/sprout/algorithm/fixed/copy_backward.hpp index a122f3bf..5603f685 100644 --- a/sprout/algorithm/fixed/copy_backward.hpp +++ b/sprout/algorithm/fixed/copy_backward.hpp @@ -124,8 +124,6 @@ namespace sprout { return sprout::fixed::copy_backward(first, last, sprout::pit()); } } // namespace fixed - - using sprout::fixed::copy_backward; } // namespace sprout #endif // #ifndef SPROUT_ALGORITHM_FIXED_COPY_BACKWARD_HPP diff --git a/sprout/algorithm/fixed/copy_if.hpp b/sprout/algorithm/fixed/copy_if.hpp index 37e9200a..4ca0cf88 100644 --- a/sprout/algorithm/fixed/copy_if.hpp +++ b/sprout/algorithm/fixed/copy_if.hpp @@ -89,8 +89,6 @@ namespace sprout { return sprout::fixed::copy_if(first, last, sprout::pit(), pred); } } // namespace fixed - - using sprout::fixed::copy_if; } // namespace sprout #endif // #ifndef SPROUT_ALGORITHM_FIXED_COPY_IF_HPP diff --git a/sprout/algorithm/fixed/copy_n.hpp b/sprout/algorithm/fixed/copy_n.hpp index fcf32022..ae3c1711 100644 --- a/sprout/algorithm/fixed/copy_n.hpp +++ b/sprout/algorithm/fixed/copy_n.hpp @@ -107,8 +107,6 @@ namespace sprout { return sprout::fixed::copy_n(first, n, sprout::pit()); } } // namespace fixed - - using sprout::fixed::copy_n; } // namespace sprout #endif // #ifndef SPROUT_ALGORITHM_FIXED_COPY_N_HPP diff --git a/sprout/algorithm/iter_swap.hpp b/sprout/algorithm/iter_swap.hpp new file mode 100644 index 00000000..e0db022d --- /dev/null +++ b/sprout/algorithm/iter_swap.hpp @@ -0,0 +1,25 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under 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) +=============================================================================*/ +#ifndef SPROUT_ALGORITHM_ITER_SWAP_HPP +#define SPROUT_ALGORITHM_ITER_SWAP_HPP + +#include +#include + +namespace sprout { + // + // 25.3.3 swap + // + template + inline SPROUT_CXX14_CONSTEXPR void + iter_swap(ForwardIterator1 a, ForwardIterator2 b) { + sprout::swap(*a, *b); + } +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_ITER_SWAP_HPP diff --git a/sprout/algorithm/modifying.hpp b/sprout/algorithm/modifying.hpp index 1e2a459c..552c952d 100644 --- a/sprout/algorithm/modifying.hpp +++ b/sprout/algorithm/modifying.hpp @@ -9,7 +9,71 @@ #define SPROUT_ALGORITHM_MODIFYIING_HPP #include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif // #ifndef SPROUT_ALGORITHM_MODIFYIING_HPP diff --git a/sprout/algorithm/move.hpp b/sprout/algorithm/move.hpp new file mode 100644 index 00000000..ecf2570c --- /dev/null +++ b/sprout/algorithm/move.hpp @@ -0,0 +1,33 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under 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) +=============================================================================*/ +#ifndef SPROUT_ALGORITHM_MOVE_HPP +#define SPROUT_ALGORITHM_MOVE_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // 25.3.2 Move + // + template< + typename InputIterator, typename OutputIterator, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + move(InputIterator first, InputIterator last, OutputIterator result) { + while (first != last) { + *result++ = sprout::move(*first++); + } + return result; + } +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_MOVE_HPP diff --git a/sprout/algorithm/move_backward.hpp b/sprout/algorithm/move_backward.hpp new file mode 100644 index 00000000..a931b846 --- /dev/null +++ b/sprout/algorithm/move_backward.hpp @@ -0,0 +1,33 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under 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) +=============================================================================*/ +#ifndef SPROUT_ALGORITHM_MOVE_BACKWARD_HPP +#define SPROUT_ALGORITHM_MOVE_BACKWARD_HPP + +#include +#include +#include +#include + +namespace sprout { + // + // 25.3.2 Move + // + template< + typename InputIterator, typename OutputIterator, + typename sprout::enabler_if::value>::type = sprout::enabler + > + inline SPROUT_CXX14_CONSTEXPR OutputIterator + move_backward(InputIterator first, InputIterator last, OutputIterator result) { + while (first != last) { + *--result = sprout::move(*--first); + } + return result; + } +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_MOVE_BACKWARD_HPP diff --git a/sprout/algorithm/swap_ranges.hpp b/sprout/algorithm/swap_ranges.hpp new file mode 100644 index 00000000..5cdaf6b3 --- /dev/null +++ b/sprout/algorithm/swap_ranges.hpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under 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) +=============================================================================*/ +#ifndef SPROUT_ALGORITHM_SWAP_RANGES_HPP +#define SPROUT_ALGORITHM_SWAP_RANGES_HPP + +#include +#include + +namespace sprout { + // + // 25.3.3 swap + // + template + inline SPROUT_CXX14_CONSTEXPR ForwardIterator2 + swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2) { + while (first1 != last1) { + sprout::iter_swap(*first1++, *first2++); + } + return first2; + } +} // namespace sprout + +#endif // #ifndef SPROUT_ALGORITHM_SWAP_RANGES_HPP diff --git a/sprout/iterator/back_insert_iterator.hpp b/sprout/iterator/back_insert_iterator.hpp index 38bb4bf5..f3e25ed8 100644 --- a/sprout/iterator/back_insert_iterator.hpp +++ b/sprout/iterator/back_insert_iterator.hpp @@ -63,6 +63,9 @@ namespace sprout { container->push_back(sprout::move(value)); return *this; } + SPROUT_CONSTEXPR back_insert_iterator& operator*() const { + return *this; + } SPROUT_CXX14_CONSTEXPR back_insert_iterator& operator*() { return *this; } diff --git a/sprout/iterator/front_insert_iterator.hpp b/sprout/iterator/front_insert_iterator.hpp index 7253796d..bffc7bdd 100644 --- a/sprout/iterator/front_insert_iterator.hpp +++ b/sprout/iterator/front_insert_iterator.hpp @@ -63,6 +63,9 @@ namespace sprout { container->push_front(sprout::move(value)); return *this; } + SPROUT_CONSTEXPR front_insert_iterator& operator*() const { + return *this; + } SPROUT_CXX14_CONSTEXPR front_insert_iterator& operator*() { return *this; } diff --git a/sprout/iterator/insert_iterator.hpp b/sprout/iterator/insert_iterator.hpp index 585ea1aa..f6525e9c 100644 --- a/sprout/iterator/insert_iterator.hpp +++ b/sprout/iterator/insert_iterator.hpp @@ -70,6 +70,9 @@ namespace sprout { container->insert(iter, sprout::move(value)); return *this; } + SPROUT_CONSTEXPR insert_iterator& operator*() const { + return *this; + } SPROUT_CXX14_CONSTEXPR insert_iterator& operator*() { return *this; } diff --git a/sprout/utility/exchange.hpp b/sprout/utility/exchange.hpp new file mode 100644 index 00000000..314b1ead --- /dev/null +++ b/sprout/utility/exchange.hpp @@ -0,0 +1,28 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under 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) +=============================================================================*/ +#ifndef SPROUT_UTILITY_EXCAHNGE_HPP +#define SPROUT_UTILITY_EXCAHNGE_HPP + +#include +#include +#include + +namespace sprout { + // + // 20.2.3 exchange + // + template + inline SPROUT_CXX14_CONSTEXPR T + exchange(T& obj, U&& new_val) { + T old_val = sprout::move(obj); + obj = sprout::forward(new_val); + return old_val; + } +} // namespace sprout + +#endif // #ifndef SPROUT_UTILITY_EXCAHNGE_HPP diff --git a/sprout/utility/operation.hpp b/sprout/utility/operation.hpp index 6bc835ab..86daf706 100644 --- a/sprout/utility/operation.hpp +++ b/sprout/utility/operation.hpp @@ -13,5 +13,6 @@ #include #include #include +#include #endif // #ifndef SPROUT_UTILITY_OPERATION_HPP diff --git a/sprout/utility/pair/pair.hpp b/sprout/utility/pair/pair.hpp index 5350c334..db2ff7ba 100644 --- a/sprout/utility/pair/pair.hpp +++ b/sprout/utility/pair/pair.hpp @@ -73,7 +73,7 @@ namespace sprout { typename U, typename V, typename > - inline sprout::pair& sprout::pair::operator=(sprout::tuples::tuple const& rhs) { + inline SPROUT_CXX14_CONSTEXPR sprout::pair& sprout::pair::operator=(sprout::tuples::tuple const& rhs) { first = sprout::tuples::get<0>(rhs); second = sprout::tuples::get<0>(rhs); return *this; @@ -83,7 +83,7 @@ namespace sprout { typename U, typename V, typename > - inline sprout::pair& sprout::pair::operator=(sprout::tuples::tuple&& rhs) { + inline SPROUT_CXX14_CONSTEXPR sprout::pair& sprout::pair::operator=(sprout::tuples::tuple&& rhs) { first = sprout::forward(sprout::tuples::get<0>(rhs)); second = sprout::forward(sprout::tuples::get<1>(rhs)); return *this; diff --git a/sprout/utility/pair/pair_decl.hpp b/sprout/utility/pair/pair_decl.hpp index ff34e533..f0d72be5 100644 --- a/sprout/utility/pair/pair_decl.hpp +++ b/sprout/utility/pair/pair_decl.hpp @@ -103,7 +103,7 @@ namespace sprout { SPROUT_CONSTEXPR pair(sprout::tuples::tuple&& other); pair& operator=(pair const& rhs) = default; - pair& operator=(pair&& rhs) + SPROUT_CXX14_CONSTEXPR pair& operator=(pair&& rhs) SPROUT_NOEXCEPT_EXPR(std::is_nothrow_move_assignable::value && std::is_nothrow_move_assignable::value) { first = sprout::forward(rhs.first); @@ -116,7 +116,7 @@ namespace sprout { std::is_assignable::value && std::is_assignable::value >::type > - pair& operator=(sprout::pair const& rhs) { + SPROUT_CXX14_CONSTEXPR pair& operator=(sprout::pair const& rhs) { first = rhs.first; second = rhs.second; return *this; @@ -127,7 +127,7 @@ namespace sprout { std::is_assignable::value && std::is_assignable::value >::type > - pair& operator=(sprout::pair&& rhs) { + SPROUT_CXX14_CONSTEXPR pair& operator=(sprout::pair&& rhs) { first = sprout::forward(rhs.first); second = sprout::forward(rhs.second); return *this; @@ -138,16 +138,16 @@ namespace sprout { std::is_assignable::value && std::is_assignable::value >::type > - pair& operator=(sprout::tuples::tuple const& rhs); + SPROUT_CXX14_CONSTEXPR pair& operator=(sprout::tuples::tuple const& rhs); template< typename U, typename V, typename = typename std::enable_if< std::is_assignable::value && std::is_assignable::value >::type > - pair& operator=(sprout::tuples::tuple&& rhs); + SPROUT_CXX14_CONSTEXPR pair& operator=(sprout::tuples::tuple&& rhs); - void swap(pair& other) + SPROUT_CXX14_CONSTEXPR void swap(pair& other) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(first, other.first)) && SPROUT_NOEXCEPT_EXPR(sprout::swap(second, other.second))) { sprout::swap(first, other.first); sprout::swap(second, other.second); @@ -158,7 +158,7 @@ namespace sprout { // swap // template - inline void + inline SPROUT_CXX14_CONSTEXPR void swap(sprout::pair& lhs, sprout::pair& rhs) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs))) { diff --git a/sprout/utility/string_ref/string_ref.hpp b/sprout/utility/string_ref/string_ref.hpp index 480ef330..8dd9e8c6 100644 --- a/sprout/utility/string_ref/string_ref.hpp +++ b/sprout/utility/string_ref/string_ref.hpp @@ -77,6 +77,7 @@ namespace sprout { private: const_pointer ptr_; size_type len_; + private: public: // construct/copy/destroy: SPROUT_CONSTEXPR basic_string_ref() @@ -100,7 +101,7 @@ namespace sprout { {} // iterators: #if SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION - iterator + SPROUT_CXX14_CONSTEXPR iterator begin() SPROUT_NOEXCEPT { return iterator(*this, 0); } @@ -108,7 +109,7 @@ namespace sprout { begin() const SPROUT_NOEXCEPT { return const_iterator(*this, 0); } - iterator + SPROUT_CXX14_CONSTEXPR iterator end() SPROUT_NOEXCEPT { return iterator(*this, size()); } @@ -117,10 +118,18 @@ namespace sprout { return const_iterator(*this, size()); } #else + SPROUT_CXX14_CONSTEXPR iterator + begin() SPROUT_NOEXCEPT { + return data(); + } SPROUT_CONSTEXPR const_iterator begin() const SPROUT_NOEXCEPT { return data(); } + SPROUT_CXX14_CONSTEXPR iterator + end() SPROUT_NOEXCEPT { + return data() + size(); + } SPROUT_CONSTEXPR const_iterator end() const SPROUT_NOEXCEPT { return data() + size(); @@ -174,7 +183,7 @@ namespace sprout { max_size() const SPROUT_NOEXCEPT { return size(); } - void + SPROUT_CXX14_CONSTEXPR void clear() { len_ = 0; } @@ -202,14 +211,14 @@ namespace sprout { return ptr_[size() - 1]; } // modifiers: - void + SPROUT_CXX14_CONSTEXPR void swap(basic_string_ref& other) SPROUT_NOEXCEPT { sprout::swap(ptr_, other.ptr_); sprout::swap(len_, other.len_); } - void + SPROUT_CXX14_CONSTEXPR void remove_prefix(size_type n) { if (n > size()) { n = size(); @@ -223,7 +232,7 @@ namespace sprout { : basic_string_ref(data() + n, size() - n) ; } - void + SPROUT_CXX14_CONSTEXPR void remove_suffix(size_type n) { if (n > size()) { n = size(); @@ -401,20 +410,21 @@ namespace sprout { SPROUT_EXPLICIT_CONVERSION operator std::basic_string() const { return std::basic_string(data(), size()); } - pointer + SPROUT_CONSTEXPR const_pointer + c_array() const SPROUT_NOEXCEPT { + return data(); + } + SPROUT_CXX14_CONSTEXPR pointer c_array() SPROUT_NOEXCEPT { return data(); } - void + // others: + SPROUT_CXX14_CONSTEXPR void rangecheck(size_type i) const { if (i >= size()) { throw std::out_of_range("basic_string_ref<>: index out of range"); } } - void - maxcheck(size_type n) const { - rangecheck(n); - } #if SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION template @@ -549,7 +559,7 @@ namespace sprout { // swap // template - inline void + inline SPROUT_CXX14_CONSTEXPR void swap(sprout::basic_string_ref& lhs, sprout::basic_string_ref& rhs) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs))) { diff --git a/sprout/utility/swap.hpp b/sprout/utility/swap.hpp index a51dcca5..718f84e1 100644 --- a/sprout/utility/swap.hpp +++ b/sprout/utility/swap.hpp @@ -8,6 +8,7 @@ #ifndef SPROUT_UTILITY_SWAP_HPP #define SPROUT_UTILITY_SWAP_HPP +#include #include #include @@ -15,20 +16,29 @@ namespace sprout_swap_detail { using std::swap; template - inline void + inline SPROUT_CXX14_CONSTEXPR void swap_impl(T& a, T& b) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(swap(a, b))) { - return swap(a, b); + swap(a, b); + } + template + inline SPROUT_CXX14_CONSTEXPR void + swap_impl(T (& a)[N], T (& b)[N]) + SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(swap(*a, *b))) + { + for (std::size_t i = 0; i < N; ++i) { + swap(a[i], b[i]); + } } } // namespace sprout_swap_detail namespace sprout { // - // swap + // 20.2.2 swap // template - inline void + inline SPROUT_CXX14_CONSTEXPR void swap(T1& lhs, T2& rhs) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout_swap_detail::swap_impl(lhs, rhs))) { diff --git a/sprout/utility/value_holder/value_holder.hpp b/sprout/utility/value_holder/value_holder.hpp index 8dc60aa7..d671dac0 100644 --- a/sprout/utility/value_holder/value_holder.hpp +++ b/sprout/utility/value_holder/value_holder.hpp @@ -236,61 +236,61 @@ namespace sprout { value_holder& operator=(value_holder const&) = default; value_holder& operator=(value_holder&&) = default; - value_holder& operator=(argument_type p) { + SPROUT_CXX14_CONSTEXPR value_holder& operator=(argument_type p) { value_holder temp(p); temp.swap(*this); return *this; } - value_holder& operator=(movable_argument_type p) { + SPROUT_CXX14_CONSTEXPR value_holder& operator=(movable_argument_type p) { value_holder temp(sprout::move(p)); temp.swap(*this); return *this; } - void swap(value_holder& other) + SPROUT_CXX14_CONSTEXPR void swap(value_holder& other) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(holder_, other.holder_))) { sprout::swap(holder_, other.holder_); } - operator reference() { + SPROUT_CXX14_CONSTEXPR operator reference() { return helper_type::ref(holder_); } SPROUT_CONSTEXPR operator mutable_or_const_reference() const { return helper_type::ref(holder_); } - reference operator*() { + SPROUT_CXX14_CONSTEXPR reference operator*() { return helper_type::ref(holder_); } SPROUT_CONSTEXPR mutable_or_const_reference operator*() const { return helper_type::ref(holder_); } - reference get() { + SPROUT_CXX14_CONSTEXPR reference get() { return helper_type::ref(holder_); } SPROUT_CONSTEXPR mutable_or_const_reference get() const { return helper_type::ref(holder_); } - reference value() { + SPROUT_CXX14_CONSTEXPR reference value() { return get(); } SPROUT_CONSTEXPR mutable_or_const_reference value() const { return get(); } - pointer operator->() SPROUT_NOEXCEPT { + SPROUT_CXX14_CONSTEXPR pointer operator->() SPROUT_NOEXCEPT { return helper_type::ptr(holder_); } SPROUT_CONSTEXPR mutable_or_const_pointer operator->() const SPROUT_NOEXCEPT { return helper_type::ptr(holder_); } - pointer get_pointer() SPROUT_NOEXCEPT { + SPROUT_CXX14_CONSTEXPR pointer get_pointer() SPROUT_NOEXCEPT { return helper_type::ptr(holder_); } SPROUT_CONSTEXPR mutable_or_const_pointer get_pointer() const SPROUT_NOEXCEPT { return helper_type::ptr(holder_); } - pointer get_ptr() SPROUT_NOEXCEPT { + SPROUT_CXX14_CONSTEXPR pointer get_ptr() SPROUT_NOEXCEPT { return get_pointer(); } SPROUT_CONSTEXPR mutable_or_const_pointer get_ptr() const SPROUT_NOEXCEPT { @@ -305,7 +305,7 @@ namespace sprout { // swap // template - inline void + inline SPROUT_CXX14_CONSTEXPR void swap(sprout::value_holder& lhs, sprout::value_holder& rhs) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs))) {