add sized_pit container

This commit is contained in:
bolero-MURAKAMI 2016-04-03 14:29:33 +09:00
parent d611090972
commit 0abea1678c
12 changed files with 577 additions and 28 deletions

View file

@ -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) {

19
sprout/sized_pit.hpp Normal file
View file

@ -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 <sprout/config.hpp>
#include <sprout/sized_pit/sized_pit.hpp>
#include <sprout/sized_pit/container.hpp>
#include <sprout/sized_pit/comparison.hpp>
#include <sprout/sized_pit/hash.hpp>
#include <sprout/sized_pit/tuple.hpp>
#include <sprout/sized_pit/type_traits.hpp>
#endif // #ifndef SPROUT_SIZED_PIT_HPP

View file

@ -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 <sprout/config.hpp>
#include <sprout/sized_pit/sized_pit.hpp>
namespace sprout {
//
// operator==
// operator!=
// operator<
// operator>
// operator<=
// operator>=
//
template<typename Container>
inline SPROUT_CONSTEXPR bool
operator==(sprout::sized_pit<Container> const& lhs, sprout::sized_pit<Container> const& rhs) {
return lhs.front() == rhs.front();
}
template<typename Container>
inline SPROUT_CONSTEXPR bool
operator!=(sprout::sized_pit<Container> const& lhs, sprout::sized_pit<Container> const& rhs) {
return !(lhs == rhs);
}
template<typename Container>
inline SPROUT_CONSTEXPR bool
operator<(sprout::sized_pit<Container> const& lhs, sprout::sized_pit<Container> const& rhs) {
return lhs.front() < rhs.front();
}
template<typename Container>
inline SPROUT_CONSTEXPR bool
operator>(sprout::sized_pit<Container> const& lhs, sprout::sized_pit<Container> const& rhs) {
return rhs < lhs;
}
template<typename Container>
inline SPROUT_CONSTEXPR bool
operator<=(sprout::sized_pit<Container> const& lhs, sprout::sized_pit<Container> const& rhs) {
return !(rhs < lhs);
}
template<typename Container>
inline SPROUT_CONSTEXPR bool
operator>=(sprout::sized_pit<Container> const& lhs, sprout::sized_pit<Container> const& rhs) {
return !(lhs < rhs);
}
} // namespace sprout
#endif // #ifndef SPROUT_SIZED_PIT_COMPARISON_HPP

View file

@ -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 <type_traits>
#include <sprout/utility/forward.hpp>
#include <sprout/sized_pit/sized_pit.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
namespace sprout {
namespace detail {
template<typename Container, typename = void>
struct sized_pit_container_construct_traits;
template<typename Container>
struct sized_pit_container_construct_traits<
sprout::sized_pit<Container>,
typename std::enable_if<sprout::is_fixed_container<Container>::value>::type
> {
public:
typedef typename sprout::container_construct_traits<Container>::copied_type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type
deep_copy(Cont&&) {
return copied_type();
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type
make(Args&&... args) {
return sprout::make<copied_type>(SPROUT_FORWARD(Args, args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type
remake(Cont&& cont, typename sprout::container_traits<sprout::sized_pit<Container> >::difference_type size, Args&&... args) {
return sprout::remake<copied_type>(SPROUT_FORWARD(Cont, cont), size, SPROUT_FORWARD(Args, args)...);
}
};
template<typename Container>
struct sized_pit_container_construct_traits<
sprout::sized_pit<Container>,
typename std::enable_if<!sprout::is_fixed_container<Container>::value>::type
> {
public:
typedef typename sprout::container_construct_traits<Container>::copied_type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type
deep_copy(Cont&&) {
return copied_type();
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type
make(Args&&... args) {
return sprout::make<copied_type>(SPROUT_FORWARD(Args, args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type
remake(Cont&& cont, typename sprout::container_traits<sprout::sized_pit<Container> >::difference_type size, Args&&... args) {
return sprout::remake<copied_type>(SPROUT_FORWARD(Cont, cont), size, SPROUT_FORWARD(Args, args)...);
}
template<typename Cont, typename InputIterator>
static SPROUT_CONSTEXPR copied_type
remake(Cont&&, typename sprout::container_traits<sprout::sized_pit<Container> >::difference_type, InputIterator first, InputIterator last) {
return copied_type(first, last);
}
};
} // namespace detail
//
// container_construct_traits
//
template<typename Container>
struct container_construct_traits<sprout::sized_pit<Container> >
: public sprout::detail::sized_pit_container_construct_traits<sprout::sized_pit<Container> >
{};
//
// container_transform_traits
//
template<typename Container>
struct container_transform_traits<sprout::sized_pit<Container> > {
public:
template<typename sprout::container_traits<sprout::sized_pit<Container> >::size_type Size>
struct rebind_size {
public:
typedef sprout::sized_pit<
typename sprout::container_transform_traits<Container>::template rebind_size<Size>::type
> type;
};
template<typename Type>
struct rebind_type {
public:
typedef sprout::sized_pit<
typename sprout::container_transform_traits<Container>::template rebind_type<Type>::type
> type;
};
};
} // namespace sprout
#endif // #ifndef SPROUT_SIZED_PIT_CONTAINER_HPP

45
sprout/sized_pit/hash.hpp Normal file
View file

@ -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 <functional>
#include <sprout/config.hpp>
#include <sprout/workaround/std/cstddef.hpp>
#include <sprout/sized_pit/sized_pit.hpp>
#include <sprout/functional/hash.hpp>
namespace sprout {
//
// hash_value
//
template<typename Container>
inline SPROUT_CONSTEXPR std::size_t
hash_value(sprout::sized_pit<Container> 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<typename Container>
struct hash<sprout::sized_pit<Container> >
: public sprout::hash<sprout::sized_pit<Container> >
{};
#if defined(__clang__)
# pragma clang diagnostic pop
#endif
} // namespace std
#endif // #ifndef SPROUT_SIZED_PIT_HASH_HPP

View file

@ -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 <utility>
#include <stdexcept>
#include <sprout/config.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/iterator/operation.hpp>
#include <sprout/iterator/reverse_iterator.hpp>
#include <sprout/iterator/value_iterator.hpp>
#include <sprout/utility/swap.hpp>
#include <sprout/utility/move.hpp>
namespace sprout {
//
// sized_pit
//
template<typename Container>
class sized_pit
: public sprout::container_traits_facade<Container>
{
private:
typedef sprout::container_traits_facade<typename std::remove_reference<Container>::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<reference> iterator;
typedef typename sprout::value_iterator<const_reference> 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<iterator> reverse_iterator;
typedef typename sprout::reverse_iterator<const_iterator> const_reverse_iterator;
public:
SPROUT_STATIC_CONSTEXPR size_type enumerable_size = sprout::detail::static_size_or_zero<facade_type>::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<typename Container>
SPROUT_CONSTEXPR_OR_CONST typename sprout::sized_pit<Container>::size_type sprout::sized_pit<Container>::enumerable_size;
//
// swap
//
template<typename Container>
inline SPROUT_CXX14_CONSTEXPR void
swap(sprout::sized_pit<Container>& lhs, sprout::sized_pit<Container>& rhs)
SPROUT_NOEXCEPT_IF_EXPR(lhs.swap(rhs))
{
lhs.swap(rhs);
}
} // namespace sprout
#include <sprout/sized_pit/container.hpp>
#endif // #ifndef SPROUT_SIZED_PIT_SIZED_PIT_HPP

View file

@ -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 <tuple>
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/workaround/std/cstddef.hpp>
#include <sprout/sized_pit/sized_pit.hpp>
#include <sprout/utility/move.hpp>
#include <sprout/tuple/tuple/tuple_element.hpp>
#include <sprout/tuple/tuple/get.hpp>
namespace sprout {
//
// tuple_get
//
template<std::size_t I, typename Container>
inline SPROUT_CONSTEXPR typename sprout::container_traits<sprout::sized_pit<Container> >::value_type&
tuple_get(sprout::sized_pit<Container>& t) SPROUT_NOEXCEPT {
static_assert(I < sprout::container_traits<sprout::sized_pit<Container> >::static_size, "tuple_get: index out of range");
return t[I];
}
template<std::size_t I, typename Container>
inline SPROUT_CONSTEXPR typename sprout::container_traits<sprout::sized_pit<Container> >::value_type const&
tuple_get(sprout::sized_pit<Container> const& t) SPROUT_NOEXCEPT {
static_assert(I < sprout::container_traits<sprout::sized_pit<Container> >::static_size, "tuple_get: index out of range");
return t[I];
}
template<std::size_t I, typename Container>
inline SPROUT_CONSTEXPR typename sprout::container_traits<sprout::sized_pit<Container> >::value_type&&
tuple_get(sprout::sized_pit<Container>&& t)
SPROUT_NOEXCEPT_IF_EXPR(sprout::move(sprout::tuples::get<I>(t)))
{
return sprout::move(sprout::tuples::get<I>(t));
}
} // namespace sprout
namespace std {
#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wmismatched-tags"
#endif
//
// tuple_size
//
template<typename Container>
struct tuple_size<sprout::sized_pit<Container> >
: public std::tuple_size<Container>
{};
//
// tuple_element
//
template<std::size_t I, typename Container>
struct tuple_element<I, sprout::sized_pit<Container> >
: public sprout::tuples::tuple_element<I, Container>
{};
#if defined(__clang__)
# pragma clang diagnostic pop
#endif
} // namespace std
#endif // #ifndef SPROUT_SIZED_PIT_TUPLE_HPP

View file

@ -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 <sprout/config.hpp>
#include <sprout/sized_pit/sized_pit.hpp>
#include <sprout/type_traits/integral_constant.hpp>
namespace sprout {
//
// is_sized_pit
//
template<typename T>
struct is_sized_pit
: public sprout::false_type
{};
template<typename T>
struct is_sized_pit<T const>
: public sprout::is_sized_pit<T>
{};
template<typename T>
struct is_sized_pit<T const volatile>
: public sprout::is_sized_pit<T>
{};
template<typename Container>
struct is_sized_pit<sprout::sized_pit<Container> >
: public sprout::true_type
{};
#if SPROUT_USE_VARIABLE_TEMPLATES
template<typename T>
SPROUT_STATIC_CONSTEXPR bool is_sized_pit_v = sprout::is_sized_pit<T>::value;
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
} // namespace sprout
#endif // #ifndef SPROUT_SIZED_PIT_TYPE_TRAITS_HPP

View file

@ -20,6 +20,7 @@
#include <sprout/functional/less_equal.hpp>
#include <sprout/functional/bind2nd.hpp>
#include <sprout/functional/bind1st.hpp>
#include <sprout/sized_pit.hpp>
namespace sprout {
//
@ -28,17 +29,20 @@ namespace sprout {
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator==(sprout::valarray<T, N> const& lhs, sprout::valarray<T, N> const& rhs) {
return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sprout::valarray<bool, N>(lhs.size()), sprout::equal_to<>());
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sized_pit_type(lhs.size()), sprout::equal_to<>());
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator==(sprout::valarray<T, N> const& lhs, T const& rhs) {
return sprout::fixed::transform(lhs.begin(), lhs.end(), sprout::valarray<bool, N>(lhs.size()), sprout::bind2nd(sprout::equal_to<>(), rhs));
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), sized_pit_type(lhs.size()), sprout::bind2nd(sprout::equal_to<>(), rhs));
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator==(T const& lhs, sprout::valarray<T, N> const& rhs) {
return sprout::fixed::transform(rhs.begin(), rhs.end(), sprout::valarray<bool, N>(rhs.size()), sprout::bind1st(sprout::equal_to<>(), lhs));
typedef sprout::sized_pit<sprout::valarray<bool, N> > 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<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator!=(sprout::valarray<T, N> const& lhs, sprout::valarray<T, N> const& rhs) {
return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sprout::valarray<bool, N>(lhs.size()), sprout::not_equal_to<>());
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sized_pit_type(lhs.size()), sprout::not_equal_to<>());
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator!=(sprout::valarray<T, N> const& lhs, T const& rhs) {
return sprout::fixed::transform(lhs.begin(), lhs.end(), sprout::valarray<bool, N>(lhs.size()), sprout::bind2nd(sprout::not_equal_to<>(), rhs));
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), sized_pit_type(lhs.size()), sprout::bind2nd(sprout::not_equal_to<>(), rhs));
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator!=(T const& lhs, sprout::valarray<T, N> const& rhs) {
return sprout::fixed::transform(rhs.begin(), rhs.end(), sprout::valarray<bool, N>(rhs.size()), sprout::bind1st(sprout::not_equal_to<>(), lhs));
typedef sprout::sized_pit<sprout::valarray<bool, N> > 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<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator<(sprout::valarray<T, N> const& lhs, sprout::valarray<T, N> const& rhs) {
return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sprout::valarray<bool, N>(lhs.size()), sprout::less<>());
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sized_pit_type(lhs.size()), sprout::less<>());
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator<(sprout::valarray<T, N> const& lhs, T const& rhs) {
return sprout::fixed::transform(lhs.begin(), lhs.end(), sprout::valarray<bool, N>(lhs.size()), sprout::bind2nd(sprout::less<>(), rhs));
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), sized_pit_type(lhs.size()), sprout::bind2nd(sprout::less<>(), rhs));
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator<(T const& lhs, sprout::valarray<T, N> const& rhs) {
return sprout::fixed::transform(rhs.begin(), rhs.end(), sprout::valarray<bool, N>(rhs.size()), sprout::bind1st(sprout::less<>(), lhs));
typedef sprout::sized_pit<sprout::valarray<bool, N> > 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<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator>(sprout::valarray<T, N> const& lhs, sprout::valarray<T, N> const& rhs) {
return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sprout::valarray<bool, N>(lhs.size()), sprout::greater<>());
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sized_pit_type(lhs.size()), sprout::greater<>());
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator>(sprout::valarray<T, N> const& lhs, T const& rhs) {
return sprout::fixed::transform(lhs.begin(), lhs.end(), sprout::valarray<bool, N>(lhs.size()), sprout::bind2nd(sprout::greater<>(), rhs));
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), sized_pit_type(lhs.size()), sprout::bind2nd(sprout::greater<>(), rhs));
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator>(T const& lhs, sprout::valarray<T, N> const& rhs) {
return sprout::fixed::transform(rhs.begin(), rhs.end(), sprout::valarray<bool, N>(rhs.size()), sprout::bind1st(sprout::greater<>(), lhs));
typedef sprout::sized_pit<sprout::valarray<bool, N> > 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<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator<=(sprout::valarray<T, N> const& lhs, sprout::valarray<T, N> const& rhs) {
return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sprout::valarray<bool, N>(lhs.size()), sprout::less_equal<>());
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sized_pit_type(lhs.size()), sprout::less_equal<>());
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator<=(sprout::valarray<T, N> const& lhs, T const& rhs) {
return sprout::fixed::transform(lhs.begin(), lhs.end(), sprout::valarray<bool, N>(lhs.size()), sprout::bind2nd(sprout::less_equal<>(), rhs));
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), sized_pit_type(lhs.size()), sprout::bind2nd(sprout::less_equal<>(), rhs));
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator<=(T const& lhs, sprout::valarray<T, N> const& rhs) {
return sprout::fixed::transform(rhs.begin(), rhs.end(), sprout::valarray<bool, N>(rhs.size()), sprout::bind1st(sprout::less_equal<>(), lhs));
typedef sprout::sized_pit<sprout::valarray<bool, N> > 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<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator>=(sprout::valarray<T, N> const& lhs, sprout::valarray<T, N> const& rhs) {
return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sprout::valarray<bool, N>(lhs.size()), sprout::greater_equal<>());
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sized_pit_type(lhs.size()), sprout::greater_equal<>());
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator>=(sprout::valarray<T, N> const& lhs, T const& rhs) {
return sprout::fixed::transform(lhs.begin(), lhs.end(), sprout::valarray<bool, N>(lhs.size()), sprout::bind2nd(sprout::greater_equal<>(), rhs));
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), sized_pit_type(lhs.size()), sprout::bind2nd(sprout::greater_equal<>(), rhs));
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator>=(T const& lhs, sprout::valarray<T, N> const& rhs) {
return sprout::fixed::transform(rhs.begin(), rhs.end(), sprout::valarray<bool, N>(rhs.size()), sprout::bind1st(sprout::greater_equal<>(), lhs));
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(rhs.begin(), rhs.end(), sized_pit_type(rhs.size()), sprout::bind1st(sprout::greater_equal<>(), lhs));
}
} // namespace sprout

View file

@ -16,6 +16,7 @@
#include <sprout/functional/logical_or.hpp>
#include <sprout/functional/bind2nd.hpp>
#include <sprout/functional/bind1st.hpp>
#include <sprout/sized_pit.hpp>
namespace sprout {
//
@ -24,17 +25,20 @@ namespace sprout {
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator&&(sprout::valarray<T, N> const& lhs, sprout::valarray<T, N> const& rhs) {
return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sprout::valarray<bool, N>(lhs.size()), sprout::logical_and<>());
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sized_pit_type(lhs.size()), sprout::logical_and<>());
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator&&(sprout::valarray<T, N> const& lhs, T const& rhs) {
return sprout::fixed::transform(lhs.begin(), lhs.end(), sprout::valarray<bool, N>(lhs.size()), sprout::bind2nd(sprout::logical_and<>(), rhs));
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), sized_pit_type(lhs.size()), sprout::bind2nd(sprout::logical_and<>(), rhs));
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator&&(T const& lhs, sprout::valarray<T, N> const& rhs) {
return sprout::fixed::transform(rhs.begin(), rhs.end(), sprout::valarray<bool, N>(rhs.size()), sprout::bind1st(sprout::logical_and<>(), lhs));
typedef sprout::sized_pit<sprout::valarray<bool, N> > 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<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator||(sprout::valarray<T, N> const& lhs, sprout::valarray<T, N> const& rhs) {
return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sprout::valarray<bool, N>(lhs.size()), sprout::logical_or<>());
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), rhs.begin(), sized_pit_type(lhs.size()), sprout::logical_or<>());
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator||(sprout::valarray<T, N> const& lhs, T const& rhs) {
return sprout::fixed::transform(lhs.begin(), lhs.end(), sprout::valarray<bool, N>(lhs.size()), sprout::bind2nd(sprout::logical_or<>(), rhs));
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(lhs.begin(), lhs.end(), sized_pit_type(lhs.size()), sprout::bind2nd(sprout::logical_or<>(), rhs));
}
template<typename T, std::size_t N>
inline SPROUT_CONSTEXPR sprout::valarray<bool, N>
operator||(T const& lhs, sprout::valarray<T, N> const& rhs) {
return sprout::fixed::transform(rhs.begin(), rhs.end(), sprout::valarray<bool, N>(rhs.size()), sprout::bind1st(sprout::logical_or<>(), lhs));
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(rhs.begin(), rhs.end(), sized_pit_type(rhs.size()), sprout::bind1st(sprout::logical_or<>(), lhs));
}
} // namespace sprout

View file

@ -342,7 +342,8 @@ namespace sprout {
}
SPROUT_CONSTEXPR valarray<bool, N>
operator!() const {
return sprout::fixed::transform<valarray<bool, N> >(begin(), end(), sprout::logical_not<>());
typedef sprout::sized_pit<sprout::valarray<bool, N> > sized_pit_type;
return sprout::fixed::transform(begin(), end(), sized_pit_type(size()), sprout::logical_not<>());
}
// computed assignment:
SPROUT_CXX14_CONSTEXPR valarray&

View file

@ -70,6 +70,7 @@
#include <sprout/range/numeric/dft.hpp>
#include <sprout/range/numeric/fft.hpp>
#include <sprout/rational.hpp>
#include <sprout/sized_pit.hpp>
#include <sprout/stateful.hpp>
#include <sprout/static_assert.hpp>
#include <sprout/static_warning.hpp>