From 0abea1678cd8618a8f62bd22535026ab6cf81567 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Sun, 3 Apr 2016 14:29:33 +0900 Subject: [PATCH] add sized_pit container --- sprout/pit/pit.hpp | 6 +- sprout/sized_pit.hpp | 19 ++++ sprout/sized_pit/comparison.hpp | 55 ++++++++++ sprout/sized_pit/container.hpp | 108 ++++++++++++++++++ sprout/sized_pit/hash.hpp | 45 ++++++++ sprout/sized_pit/sized_pit.hpp | 182 +++++++++++++++++++++++++++++++ sprout/sized_pit/tuple.hpp | 70 ++++++++++++ sprout/sized_pit/type_traits.hpp | 42 +++++++ sprout/valarray/comparison.hpp | 55 +++++++--- sprout/valarray/logical.hpp | 19 +++- sprout/valarray/valarray.hpp | 3 +- testspr/header_all.hpp | 1 + 12 files changed, 577 insertions(+), 28 deletions(-) create mode 100644 sprout/sized_pit.hpp create mode 100644 sprout/sized_pit/comparison.hpp create mode 100644 sprout/sized_pit/container.hpp create mode 100644 sprout/sized_pit/hash.hpp create mode 100644 sprout/sized_pit/sized_pit.hpp create mode 100644 sprout/sized_pit/tuple.hpp create mode 100644 sprout/sized_pit/type_traits.hpp diff --git a/sprout/pit/pit.hpp b/sprout/pit/pit.hpp index 24f54eda..d994a291 100644 --- a/sprout/pit/pit.hpp +++ b/sprout/pit/pit.hpp @@ -114,13 +114,13 @@ namespace sprout { } // capacity: SPROUT_CONSTEXPR size_type size() const SPROUT_NOEXCEPT { - return enumerable_size; + return max_size(); } SPROUT_CONSTEXPR size_type max_size() const SPROUT_NOEXCEPT { - return size(); + return enumerable_size; } SPROUT_CONSTEXPR bool empty() const SPROUT_NOEXCEPT { - return enumerable_size == 0; + return size() == 0; } // element access: SPROUT_CXX14_CONSTEXPR reference operator[](size_type) { diff --git a/sprout/sized_pit.hpp b/sprout/sized_pit.hpp new file mode 100644 index 00000000..4d5d859d --- /dev/null +++ b/sprout/sized_pit.hpp @@ -0,0 +1,19 @@ +/*============================================================================= + Copyright (c) 2011-2016 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_SIZED_PIT_HPP +#define SPROUT_SIZED_PIT_HPP + +#include +#include +#include +#include +#include +#include +#include + +#endif // #ifndef SPROUT_SIZED_PIT_HPP diff --git a/sprout/sized_pit/comparison.hpp b/sprout/sized_pit/comparison.hpp new file mode 100644 index 00000000..4d514f0c --- /dev/null +++ b/sprout/sized_pit/comparison.hpp @@ -0,0 +1,55 @@ +/*============================================================================= + Copyright (c) 2011-2016 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_SIZED_PIT_COMPARISON_HPP +#define SPROUT_SIZED_PIT_COMPARISON_HPP + +#include +#include + +namespace sprout { + // + // operator== + // operator!= + // operator< + // operator> + // operator<= + // operator>= + // + template + inline SPROUT_CONSTEXPR bool + operator==(sprout::sized_pit const& lhs, sprout::sized_pit const& rhs) { + return lhs.front() == rhs.front(); + } + template + inline SPROUT_CONSTEXPR bool + operator!=(sprout::sized_pit const& lhs, sprout::sized_pit const& rhs) { + return !(lhs == rhs); + } + template + inline SPROUT_CONSTEXPR bool + operator<(sprout::sized_pit const& lhs, sprout::sized_pit const& rhs) { + return lhs.front() < rhs.front(); + } + template + inline SPROUT_CONSTEXPR bool + operator>(sprout::sized_pit const& lhs, sprout::sized_pit const& rhs) { + return rhs < lhs; + } + template + inline SPROUT_CONSTEXPR bool + operator<=(sprout::sized_pit const& lhs, sprout::sized_pit const& rhs) { + return !(rhs < lhs); + } + template + inline SPROUT_CONSTEXPR bool + operator>=(sprout::sized_pit const& lhs, sprout::sized_pit const& rhs) { + return !(lhs < rhs); + } +} // namespace sprout + +#endif // #ifndef SPROUT_SIZED_PIT_COMPARISON_HPP diff --git a/sprout/sized_pit/container.hpp b/sprout/sized_pit/container.hpp new file mode 100644 index 00000000..f67125e3 --- /dev/null +++ b/sprout/sized_pit/container.hpp @@ -0,0 +1,108 @@ +/*============================================================================= + Copyright (c) 2011-2016 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_SIZED_PIT_CONTAINER_HPP +#define SPROUT_SIZED_PIT_CONTAINER_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace detail { + template + struct sized_pit_container_construct_traits; + + template + struct sized_pit_container_construct_traits< + sprout::sized_pit, + typename std::enable_if::value>::type + > { + public: + typedef typename sprout::container_construct_traits::copied_type copied_type; + public: + template + static SPROUT_CONSTEXPR copied_type + deep_copy(Cont&&) { + return copied_type(); + } + template + static SPROUT_CONSTEXPR copied_type + make(Args&&... args) { + return sprout::make(SPROUT_FORWARD(Args, args)...); + } + template + static SPROUT_CONSTEXPR copied_type + remake(Cont&& cont, typename sprout::container_traits >::difference_type size, Args&&... args) { + return sprout::remake(SPROUT_FORWARD(Cont, cont), size, SPROUT_FORWARD(Args, args)...); + } + }; + + template + struct sized_pit_container_construct_traits< + sprout::sized_pit, + typename std::enable_if::value>::type + > { + public: + typedef typename sprout::container_construct_traits::copied_type copied_type; + public: + template + static SPROUT_CONSTEXPR copied_type + deep_copy(Cont&&) { + return copied_type(); + } + template + static SPROUT_CONSTEXPR copied_type + make(Args&&... args) { + return sprout::make(SPROUT_FORWARD(Args, args)...); + } + template + static SPROUT_CONSTEXPR copied_type + remake(Cont&& cont, typename sprout::container_traits >::difference_type size, Args&&... args) { + return sprout::remake(SPROUT_FORWARD(Cont, cont), size, SPROUT_FORWARD(Args, args)...); + } + template + static SPROUT_CONSTEXPR copied_type + remake(Cont&&, typename sprout::container_traits >::difference_type, InputIterator first, InputIterator last) { + return copied_type(first, last); + } + }; + } // namespace detail + // + // container_construct_traits + // + template + struct container_construct_traits > + : public sprout::detail::sized_pit_container_construct_traits > + {}; + + // + // container_transform_traits + // + template + struct container_transform_traits > { + public: + template >::size_type Size> + struct rebind_size { + public: + typedef sprout::sized_pit< + typename sprout::container_transform_traits::template rebind_size::type + > type; + }; + template + struct rebind_type { + public: + typedef sprout::sized_pit< + typename sprout::container_transform_traits::template rebind_type::type + > type; + }; + }; +} // namespace sprout + +#endif // #ifndef SPROUT_SIZED_PIT_CONTAINER_HPP diff --git a/sprout/sized_pit/hash.hpp b/sprout/sized_pit/hash.hpp new file mode 100644 index 00000000..3564ea56 --- /dev/null +++ b/sprout/sized_pit/hash.hpp @@ -0,0 +1,45 @@ +/*============================================================================= + Copyright (c) 2011-2016 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_SIZED_PIT_HASH_HPP +#define SPROUT_SIZED_PIT_HASH_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + // + // hash_value + // + template + inline SPROUT_CONSTEXPR std::size_t + hash_value(sprout::sized_pit const& v) { + return sprout::to_hash(v.elem); + } +} // namespace sprout + +namespace std { +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wmismatched-tags" +#endif + // + // hash + // + template + struct hash > + : public sprout::hash > + {}; +#if defined(__clang__) +# pragma clang diagnostic pop +#endif +} // namespace std + +#endif // #ifndef SPROUT_SIZED_PIT_HASH_HPP diff --git a/sprout/sized_pit/sized_pit.hpp b/sprout/sized_pit/sized_pit.hpp new file mode 100644 index 00000000..bbf93735 --- /dev/null +++ b/sprout/sized_pit/sized_pit.hpp @@ -0,0 +1,182 @@ +/*============================================================================= + Copyright (c) 2011-2016 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_SIZED_PIT_SIZED_PIT_HPP +#define SPROUT_SIZED_PIT_SIZED_PIT_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace sprout { + // + // sized_pit + // + template + class sized_pit + : public sprout::container_traits_facade + { + private: + typedef sprout::container_traits_facade::type> facade_type; + public: + typedef Container container_type; + typedef typename facade_type::value_type value_type; + typedef typename facade_type::reference reference; + typedef typename facade_type::const_reference const_reference; + typedef typename sprout::value_iterator iterator; + typedef typename sprout::value_iterator const_iterator; + typedef typename facade_type::size_type size_type; + typedef typename facade_type::difference_type difference_type; + typedef typename facade_type::pointer pointer; + typedef typename facade_type::const_pointer const_pointer; + typedef typename sprout::reverse_iterator reverse_iterator; + typedef typename sprout::reverse_iterator const_reverse_iterator; + public: + SPROUT_STATIC_CONSTEXPR size_type enumerable_size = sprout::detail::static_size_or_zero::value; + private: + value_type elem; + size_type size_; + public: + SPROUT_CONSTEXPR sized_pit() + : elem(), size_() + {} + sized_pit(sized_pit const&) = default; + explicit SPROUT_CONSTEXPR sized_pit(size_type size) + : elem(), size_(size) + {} + SPROUT_CONSTEXPR sized_pit(size_type size, value_type const& t) + : elem(t), size_(size) + {} + SPROUT_CXX14_CONSTEXPR sized_pit& operator=(sized_pit const& rhs) { + elem = rhs.elem; + return *this; + } + SPROUT_CXX14_CONSTEXPR sized_pit& operator=(sized_pit&& rhs) { + elem = sprout::move(rhs.elem); + return *this; + } + SPROUT_CXX14_CONSTEXPR sized_pit& operator=(value_type const& rhs) { + elem = rhs; + return *this; + } + SPROUT_CXX14_CONSTEXPR sized_pit& operator=(value_type&& rhs) { + elem = sprout::move(rhs); + return *this; + } + SPROUT_CXX14_CONSTEXPR void swap(sized_pit& other) + SPROUT_NOEXCEPT_IF_EXPR(sprout::swap(elem, other.elem)) + { + sprout::swap(elem, other.elem); + } + // iterators: + SPROUT_CXX14_CONSTEXPR iterator begin() { + return iterator(elem, enumerable_size); + } + SPROUT_CONSTEXPR const_iterator begin() const { + return const_iterator(elem, enumerable_size); + } + SPROUT_CXX14_CONSTEXPR iterator end() SPROUT_NOEXCEPT { + return iterator(elem, 0); + } + SPROUT_CONSTEXPR const_iterator end() const SPROUT_NOEXCEPT { + return const_iterator(elem, 0); + } + SPROUT_CXX14_CONSTEXPR reverse_iterator rbegin() SPROUT_NOEXCEPT { + return reverse_iterator(end()); + } + SPROUT_CONSTEXPR const_reverse_iterator rbegin() const SPROUT_NOEXCEPT { + return const_reverse_iterator(end()); + } + SPROUT_CXX14_CONSTEXPR reverse_iterator rend() SPROUT_NOEXCEPT { + return reverse_iterator(begin()); + } + SPROUT_CONSTEXPR const_reverse_iterator rend() const SPROUT_NOEXCEPT { + return const_reverse_iterator(begin()); + } + SPROUT_CONSTEXPR const_iterator cbegin() const SPROUT_NOEXCEPT { + return const_iterator(elem, enumerable_size); + } + SPROUT_CONSTEXPR const_iterator cend() const SPROUT_NOEXCEPT { + return const_iterator(elem, 0); + } + SPROUT_CONSTEXPR const_reverse_iterator crbegin() const SPROUT_NOEXCEPT { + return const_reverse_iterator(end()); + } + SPROUT_CONSTEXPR const_reverse_iterator crend() const SPROUT_NOEXCEPT { + return const_reverse_iterator(begin()); + } + // capacity: + SPROUT_CONSTEXPR size_type size() const SPROUT_NOEXCEPT { + return size_; + } + SPROUT_CONSTEXPR size_type max_size() const SPROUT_NOEXCEPT { + return enumerable_size; + } + SPROUT_CONSTEXPR bool empty() const SPROUT_NOEXCEPT { + return size() == 0; + } + // element access: + SPROUT_CXX14_CONSTEXPR reference operator[](size_type) { + return elem; + } + SPROUT_CONSTEXPR const_reference operator[](size_type) const { + return elem; + } + SPROUT_CXX14_CONSTEXPR reference at(size_type i) { + return i < size() ? elem + : (throw std::out_of_range("sized_pit<>: index out of range"), elem) + ; + } + SPROUT_CONSTEXPR const_reference at(size_type i) const { + return i < size() ? elem + : (throw std::out_of_range("sized_pit<>: index out of range"), elem) + ; + } + SPROUT_CXX14_CONSTEXPR reference front() { + return elem; + } + SPROUT_CONSTEXPR const_reference front() const { + return elem; + } + SPROUT_CXX14_CONSTEXPR reference back() { + return elem; + } + SPROUT_CONSTEXPR const_reference back() const { + return elem; + } + // others: + SPROUT_CXX14_CONSTEXPR void rangecheck(size_type i) const { + return i >= size() ? throw std::out_of_range("sized_pit<>: index out of range") + : (void)0 + ; + } + }; + template + SPROUT_CONSTEXPR_OR_CONST typename sprout::sized_pit::size_type sprout::sized_pit::enumerable_size; + + // + // swap + // + template + inline SPROUT_CXX14_CONSTEXPR void + swap(sprout::sized_pit& lhs, sprout::sized_pit& rhs) + SPROUT_NOEXCEPT_IF_EXPR(lhs.swap(rhs)) + { + lhs.swap(rhs); + } +} // namespace sprout + +#include + +#endif // #ifndef SPROUT_SIZED_PIT_SIZED_PIT_HPP diff --git a/sprout/sized_pit/tuple.hpp b/sprout/sized_pit/tuple.hpp new file mode 100644 index 00000000..590d103b --- /dev/null +++ b/sprout/sized_pit/tuple.hpp @@ -0,0 +1,70 @@ +/*============================================================================= + Copyright (c) 2011-2016 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_SIZED_PIT_TUPLE_HPP +#define SPROUT_SIZED_PIT_TUPLE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace sprout { + // + // tuple_get + // + template + inline SPROUT_CONSTEXPR typename sprout::container_traits >::value_type& + tuple_get(sprout::sized_pit& t) SPROUT_NOEXCEPT { + static_assert(I < sprout::container_traits >::static_size, "tuple_get: index out of range"); + return t[I]; + } + template + inline SPROUT_CONSTEXPR typename sprout::container_traits >::value_type const& + tuple_get(sprout::sized_pit const& t) SPROUT_NOEXCEPT { + static_assert(I < sprout::container_traits >::static_size, "tuple_get: index out of range"); + return t[I]; + } + template + inline SPROUT_CONSTEXPR typename sprout::container_traits >::value_type&& + tuple_get(sprout::sized_pit&& t) + SPROUT_NOEXCEPT_IF_EXPR(sprout::move(sprout::tuples::get(t))) + { + return sprout::move(sprout::tuples::get(t)); + } +} // namespace sprout + +namespace std { +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wmismatched-tags" +#endif + // + // tuple_size + // + template + struct tuple_size > + : public std::tuple_size + {}; + + // + // tuple_element + // + template + struct tuple_element > + : public sprout::tuples::tuple_element + {}; +#if defined(__clang__) +# pragma clang diagnostic pop +#endif +} // namespace std + +#endif // #ifndef SPROUT_SIZED_PIT_TUPLE_HPP diff --git a/sprout/sized_pit/type_traits.hpp b/sprout/sized_pit/type_traits.hpp new file mode 100644 index 00000000..78f7ea94 --- /dev/null +++ b/sprout/sized_pit/type_traits.hpp @@ -0,0 +1,42 @@ +/*============================================================================= + Copyright (c) 2011-2016 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_SIZED_PIT_TYPE_TRAITS_HPP +#define SPROUT_SIZED_PIT_TYPE_TRAITS_HPP + +#include +#include +#include + +namespace sprout { + // + // is_sized_pit + // + template + struct is_sized_pit + : public sprout::false_type + {}; + template + struct is_sized_pit + : public sprout::is_sized_pit + {}; + template + struct is_sized_pit + : public sprout::is_sized_pit + {}; + template + struct is_sized_pit > + : public sprout::true_type + {}; + +#if SPROUT_USE_VARIABLE_TEMPLATES + template + SPROUT_STATIC_CONSTEXPR bool is_sized_pit_v = sprout::is_sized_pit::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES +} // namespace sprout + +#endif // #ifndef SPROUT_SIZED_PIT_TYPE_TRAITS_HPP diff --git a/sprout/valarray/comparison.hpp b/sprout/valarray/comparison.hpp index e8c3f3f8..56b8f180 100644 --- a/sprout/valarray/comparison.hpp +++ b/sprout/valarray/comparison.hpp @@ -20,6 +20,7 @@ #include #include #include +#include namespace sprout { // @@ -28,17 +29,20 @@ namespace sprout { template inline SPROUT_CONSTEXPR sprout::valarray operator==(sprout::valarray const& lhs, sprout::valarray const& rhs) { - return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sprout::valarray(lhs.size()), sprout::equal_to<>()); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sized_pit_type(lhs.size()), sprout::equal_to<>()); } template inline SPROUT_CONSTEXPR sprout::valarray operator==(sprout::valarray const& lhs, T const& rhs) { - return sprout::fixed::transform(lhs.begin(), lhs.end(), sprout::valarray(lhs.size()), sprout::bind2nd(sprout::equal_to<>(), rhs)); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(lhs.begin(), lhs.end(), sized_pit_type(lhs.size()), sprout::bind2nd(sprout::equal_to<>(), rhs)); } template inline SPROUT_CONSTEXPR sprout::valarray operator==(T const& lhs, sprout::valarray const& rhs) { - return sprout::fixed::transform(rhs.begin(), rhs.end(), sprout::valarray(rhs.size()), sprout::bind1st(sprout::equal_to<>(), lhs)); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(rhs.begin(), rhs.end(), sized_pit_type(rhs.size()), sprout::bind1st(sprout::equal_to<>(), lhs)); } // // operator!= @@ -46,17 +50,20 @@ namespace sprout { template inline SPROUT_CONSTEXPR sprout::valarray operator!=(sprout::valarray const& lhs, sprout::valarray const& rhs) { - return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sprout::valarray(lhs.size()), sprout::not_equal_to<>()); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sized_pit_type(lhs.size()), sprout::not_equal_to<>()); } template inline SPROUT_CONSTEXPR sprout::valarray operator!=(sprout::valarray const& lhs, T const& rhs) { - return sprout::fixed::transform(lhs.begin(), lhs.end(), sprout::valarray(lhs.size()), sprout::bind2nd(sprout::not_equal_to<>(), rhs)); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(lhs.begin(), lhs.end(), sized_pit_type(lhs.size()), sprout::bind2nd(sprout::not_equal_to<>(), rhs)); } template inline SPROUT_CONSTEXPR sprout::valarray operator!=(T const& lhs, sprout::valarray const& rhs) { - return sprout::fixed::transform(rhs.begin(), rhs.end(), sprout::valarray(rhs.size()), sprout::bind1st(sprout::not_equal_to<>(), lhs)); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(rhs.begin(), rhs.end(), sized_pit_type(rhs.size()), sprout::bind1st(sprout::not_equal_to<>(), lhs)); } // // operator< @@ -64,17 +71,20 @@ namespace sprout { template inline SPROUT_CONSTEXPR sprout::valarray operator<(sprout::valarray const& lhs, sprout::valarray const& rhs) { - return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sprout::valarray(lhs.size()), sprout::less<>()); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sized_pit_type(lhs.size()), sprout::less<>()); } template inline SPROUT_CONSTEXPR sprout::valarray operator<(sprout::valarray const& lhs, T const& rhs) { - return sprout::fixed::transform(lhs.begin(), lhs.end(), sprout::valarray(lhs.size()), sprout::bind2nd(sprout::less<>(), rhs)); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(lhs.begin(), lhs.end(), sized_pit_type(lhs.size()), sprout::bind2nd(sprout::less<>(), rhs)); } template inline SPROUT_CONSTEXPR sprout::valarray operator<(T const& lhs, sprout::valarray const& rhs) { - return sprout::fixed::transform(rhs.begin(), rhs.end(), sprout::valarray(rhs.size()), sprout::bind1st(sprout::less<>(), lhs)); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(rhs.begin(), rhs.end(), sized_pit_type(rhs.size()), sprout::bind1st(sprout::less<>(), lhs)); } // // operator> @@ -82,17 +92,20 @@ namespace sprout { template inline SPROUT_CONSTEXPR sprout::valarray operator>(sprout::valarray const& lhs, sprout::valarray const& rhs) { - return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sprout::valarray(lhs.size()), sprout::greater<>()); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sized_pit_type(lhs.size()), sprout::greater<>()); } template inline SPROUT_CONSTEXPR sprout::valarray operator>(sprout::valarray const& lhs, T const& rhs) { - return sprout::fixed::transform(lhs.begin(), lhs.end(), sprout::valarray(lhs.size()), sprout::bind2nd(sprout::greater<>(), rhs)); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(lhs.begin(), lhs.end(), sized_pit_type(lhs.size()), sprout::bind2nd(sprout::greater<>(), rhs)); } template inline SPROUT_CONSTEXPR sprout::valarray operator>(T const& lhs, sprout::valarray const& rhs) { - return sprout::fixed::transform(rhs.begin(), rhs.end(), sprout::valarray(rhs.size()), sprout::bind1st(sprout::greater<>(), lhs)); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(rhs.begin(), rhs.end(), sized_pit_type(rhs.size()), sprout::bind1st(sprout::greater<>(), lhs)); } // // operator<= @@ -100,17 +113,20 @@ namespace sprout { template inline SPROUT_CONSTEXPR sprout::valarray operator<=(sprout::valarray const& lhs, sprout::valarray const& rhs) { - return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sprout::valarray(lhs.size()), sprout::less_equal<>()); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sized_pit_type(lhs.size()), sprout::less_equal<>()); } template inline SPROUT_CONSTEXPR sprout::valarray operator<=(sprout::valarray const& lhs, T const& rhs) { - return sprout::fixed::transform(lhs.begin(), lhs.end(), sprout::valarray(lhs.size()), sprout::bind2nd(sprout::less_equal<>(), rhs)); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(lhs.begin(), lhs.end(), sized_pit_type(lhs.size()), sprout::bind2nd(sprout::less_equal<>(), rhs)); } template inline SPROUT_CONSTEXPR sprout::valarray operator<=(T const& lhs, sprout::valarray const& rhs) { - return sprout::fixed::transform(rhs.begin(), rhs.end(), sprout::valarray(rhs.size()), sprout::bind1st(sprout::less_equal<>(), lhs)); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(rhs.begin(), rhs.end(), sized_pit_type(rhs.size()), sprout::bind1st(sprout::less_equal<>(), lhs)); } // // operator>= @@ -118,17 +134,20 @@ namespace sprout { template inline SPROUT_CONSTEXPR sprout::valarray operator>=(sprout::valarray const& lhs, sprout::valarray const& rhs) { - return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sprout::valarray(lhs.size()), sprout::greater_equal<>()); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sized_pit_type(lhs.size()), sprout::greater_equal<>()); } template inline SPROUT_CONSTEXPR sprout::valarray operator>=(sprout::valarray const& lhs, T const& rhs) { - return sprout::fixed::transform(lhs.begin(), lhs.end(), sprout::valarray(lhs.size()), sprout::bind2nd(sprout::greater_equal<>(), rhs)); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(lhs.begin(), lhs.end(), sized_pit_type(lhs.size()), sprout::bind2nd(sprout::greater_equal<>(), rhs)); } template inline SPROUT_CONSTEXPR sprout::valarray operator>=(T const& lhs, sprout::valarray const& rhs) { - return sprout::fixed::transform(rhs.begin(), rhs.end(), sprout::valarray(rhs.size()), sprout::bind1st(sprout::greater_equal<>(), lhs)); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(rhs.begin(), rhs.end(), sized_pit_type(rhs.size()), sprout::bind1st(sprout::greater_equal<>(), lhs)); } } // namespace sprout diff --git a/sprout/valarray/logical.hpp b/sprout/valarray/logical.hpp index ddc3ba7e..5a69764a 100644 --- a/sprout/valarray/logical.hpp +++ b/sprout/valarray/logical.hpp @@ -16,6 +16,7 @@ #include #include #include +#include namespace sprout { // @@ -24,17 +25,20 @@ namespace sprout { template inline SPROUT_CONSTEXPR sprout::valarray operator&&(sprout::valarray const& lhs, sprout::valarray const& rhs) { - return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sprout::valarray(lhs.size()), sprout::logical_and<>()); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sized_pit_type(lhs.size()), sprout::logical_and<>()); } template inline SPROUT_CONSTEXPR sprout::valarray operator&&(sprout::valarray const& lhs, T const& rhs) { - return sprout::fixed::transform(lhs.begin(), lhs.end(), sprout::valarray(lhs.size()), sprout::bind2nd(sprout::logical_and<>(), rhs)); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(lhs.begin(), lhs.end(), sized_pit_type(lhs.size()), sprout::bind2nd(sprout::logical_and<>(), rhs)); } template inline SPROUT_CONSTEXPR sprout::valarray operator&&(T const& lhs, sprout::valarray const& rhs) { - return sprout::fixed::transform(rhs.begin(), rhs.end(), sprout::valarray(rhs.size()), sprout::bind1st(sprout::logical_and<>(), lhs)); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(rhs.begin(), rhs.end(), sized_pit_type(rhs.size()), sprout::bind1st(sprout::logical_and<>(), lhs)); } // // operator|| @@ -42,17 +46,20 @@ namespace sprout { template inline SPROUT_CONSTEXPR sprout::valarray operator||(sprout::valarray const& lhs, sprout::valarray const& rhs) { - return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sprout::valarray(lhs.size()), sprout::logical_or<>()); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sized_pit_type(lhs.size()), sprout::logical_or<>()); } template inline SPROUT_CONSTEXPR sprout::valarray operator||(sprout::valarray const& lhs, T const& rhs) { - return sprout::fixed::transform(lhs.begin(), lhs.end(), sprout::valarray(lhs.size()), sprout::bind2nd(sprout::logical_or<>(), rhs)); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(lhs.begin(), lhs.end(), sized_pit_type(lhs.size()), sprout::bind2nd(sprout::logical_or<>(), rhs)); } template inline SPROUT_CONSTEXPR sprout::valarray operator||(T const& lhs, sprout::valarray const& rhs) { - return sprout::fixed::transform(rhs.begin(), rhs.end(), sprout::valarray(rhs.size()), sprout::bind1st(sprout::logical_or<>(), lhs)); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(rhs.begin(), rhs.end(), sized_pit_type(rhs.size()), sprout::bind1st(sprout::logical_or<>(), lhs)); } } // namespace sprout diff --git a/sprout/valarray/valarray.hpp b/sprout/valarray/valarray.hpp index 22a7b19f..786a5a75 100644 --- a/sprout/valarray/valarray.hpp +++ b/sprout/valarray/valarray.hpp @@ -342,7 +342,8 @@ namespace sprout { } SPROUT_CONSTEXPR valarray operator!() const { - return sprout::fixed::transform >(begin(), end(), sprout::logical_not<>()); + typedef sprout::sized_pit > sized_pit_type; + return sprout::fixed::transform(begin(), end(), sized_pit_type(size()), sprout::logical_not<>()); } // computed assignment: SPROUT_CXX14_CONSTEXPR valarray& diff --git a/testspr/header_all.hpp b/testspr/header_all.hpp index e055e8b1..b2c9fd3f 100644 --- a/testspr/header_all.hpp +++ b/testspr/header_all.hpp @@ -70,6 +70,7 @@ #include #include #include +#include #include #include #include