mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-05-10 09:23:30 +00:00
adapt div_t container interface
This commit is contained in:
parent
478c21a300
commit
913dc8ca44
6 changed files with 319 additions and 49 deletions
|
@ -15,12 +15,16 @@
|
||||||
#endif
|
#endif
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
#include <tuple>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/workaround/std/cstddef.hpp>
|
#include <sprout/workaround/std/cstddef.hpp>
|
||||||
#include <sprout/functional/hash.hpp>
|
#include <sprout/functional/hash.hpp>
|
||||||
#include <sprout/utility/move.hpp>
|
#include <sprout/utility/move.hpp>
|
||||||
|
#include <sprout/tuple/tuple/get.hpp>
|
||||||
|
#include <sprout/container/traits.hpp>
|
||||||
#include <sprout/type_traits/integral_constant.hpp>
|
#include <sprout/type_traits/integral_constant.hpp>
|
||||||
#include <sprout/type_traits/identity.hpp>
|
#include <sprout/type_traits/identity.hpp>
|
||||||
|
#include <sprout/cstdlib/div.hpp>
|
||||||
#include <sprout/detail/nil_base.hpp>
|
#include <sprout/detail/nil_base.hpp>
|
||||||
|
|
||||||
namespace sprout {
|
namespace sprout {
|
||||||
|
@ -199,4 +203,37 @@ namespace sprout {
|
||||||
}
|
}
|
||||||
} // namespace sprout
|
} // namespace sprout
|
||||||
|
|
||||||
|
namespace sprout {
|
||||||
|
//
|
||||||
|
// container_traits
|
||||||
|
//
|
||||||
|
SPROUT_DETAIL_DIV_T_CONTAINER_TRAITS_IMPL(std::intmax_t, sprout::imaxdiv_t);
|
||||||
|
|
||||||
|
//
|
||||||
|
// container_range_traits
|
||||||
|
//
|
||||||
|
SPROUT_DETAIL_DIV_T_CONTAINER_RANGE_TRAITS_IMPL(std::intmax_t, sprout::imaxdiv_t);
|
||||||
|
|
||||||
|
//
|
||||||
|
// container_construct_traits
|
||||||
|
//
|
||||||
|
SPROUT_DETAIL_DIV_T_CONTAINER_CONSTRUCT_TRAITS_IMPL(std::intmax_t, sprout::imaxdiv_t);
|
||||||
|
|
||||||
|
//
|
||||||
|
// container_transform_traits
|
||||||
|
//
|
||||||
|
# define SPROUT_DETAIL_DIV_T_CONTAINER_TRANSFORM_TRAITS2_IMPL(INT_T, DIV_T) \
|
||||||
|
template<> \
|
||||||
|
struct container_transform_traits<DIV_T> { \
|
||||||
|
public: \
|
||||||
|
template<typename Type> \
|
||||||
|
struct rebind_type { \
|
||||||
|
public: \
|
||||||
|
typedef typename sprout::detail::div_t_traits2<Type>::type type; \
|
||||||
|
}; \
|
||||||
|
}
|
||||||
|
|
||||||
|
SPROUT_DETAIL_DIV_T_CONTAINER_TRANSFORM_TRAITS2_IMPL(std::intmax_t, sprout::imaxdiv_t);
|
||||||
|
} // namespace sprout
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_CINTTYPES_DIV_HPP
|
#endif // #ifndef SPROUT_CINTTYPES_DIV_HPP
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <sprout/type_traits/is_unsigned.hpp>
|
#include <sprout/type_traits/is_unsigned.hpp>
|
||||||
#include <sprout/iterator/operation.hpp>
|
#include <sprout/iterator/operation.hpp>
|
||||||
#include <sprout/ctype/ascii.hpp>
|
#include <sprout/ctype/ascii.hpp>
|
||||||
|
#include <sprout/static_assert.hpp>
|
||||||
#include <sprout/detail/char_literal.hpp>
|
#include <sprout/detail/char_literal.hpp>
|
||||||
#include <sprout/detail/char_type_of_consecutive.hpp>
|
#include <sprout/detail/char_type_of_consecutive.hpp>
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,22 @@
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
#include <tuple>
|
||||||
#include <sprout/config.hpp>
|
#include <sprout/config.hpp>
|
||||||
#include <sprout/workaround/std/cstddef.hpp>
|
#include <sprout/workaround/std/cstddef.hpp>
|
||||||
#include <sprout/functional/hash.hpp>
|
#include <sprout/functional/hash.hpp>
|
||||||
|
#include <sprout/iterator/index_iterator.hpp>
|
||||||
|
#include <sprout/iterator/reverse_iterator.hpp>
|
||||||
|
#include <sprout/functional/transparent.hpp>
|
||||||
|
#include <sprout/utility/forward.hpp>
|
||||||
#include <sprout/utility/move.hpp>
|
#include <sprout/utility/move.hpp>
|
||||||
|
#include <sprout/tuple/tuple/get.hpp>
|
||||||
|
#include <sprout/container/traits.hpp>
|
||||||
#include <sprout/type_traits/integral_constant.hpp>
|
#include <sprout/type_traits/integral_constant.hpp>
|
||||||
#include <sprout/type_traits/identity.hpp>
|
#include <sprout/type_traits/identity.hpp>
|
||||||
#include <sprout/detail/nil_base.hpp>
|
#include <sprout/detail/nil_base.hpp>
|
||||||
|
#include <sprout/detail/static_size.hpp>
|
||||||
|
#include <sprout/assert.hpp>
|
||||||
|
|
||||||
namespace sprout {
|
namespace sprout {
|
||||||
//
|
//
|
||||||
|
@ -330,4 +339,206 @@ namespace sprout {
|
||||||
}
|
}
|
||||||
} // namespace sprout
|
} // namespace sprout
|
||||||
|
|
||||||
|
namespace sprout {
|
||||||
|
namespace detail {
|
||||||
|
template<typename Div>
|
||||||
|
SPROUT_CONSTEXPR typename std::remove_reference<decltype(std::declval<Div>().quot)>::type&
|
||||||
|
div_at(Div& d, std::size_t i)
|
||||||
|
SPROUT_NOEXCEPT_IF_EXPR(std::declval<Div>().quot)
|
||||||
|
{
|
||||||
|
return i == 0 ? d.quot
|
||||||
|
: i == 1 ? d.rem
|
||||||
|
: (SPROUT_ASSERT(i < 2), d.quot)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
template<typename Div>
|
||||||
|
SPROUT_CONSTEXPR typename std::remove_reference<decltype(std::declval<Div>().quot)>::type const&
|
||||||
|
div_at(Div const& d, std::size_t i)
|
||||||
|
SPROUT_NOEXCEPT_IF_EXPR(std::declval<Div>().quot)
|
||||||
|
{
|
||||||
|
return i == 0 ? d.quot
|
||||||
|
: i == 1 ? d.rem
|
||||||
|
: (SPROUT_ASSERT(i < 2), d.quot)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T = void>
|
||||||
|
struct div_at_f;
|
||||||
|
template<>
|
||||||
|
struct div_at_f<void>
|
||||||
|
: public sprout::transparent<>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
template<typename T, typename U>
|
||||||
|
SPROUT_CONSTEXPR decltype(sprout::detail::div_at(std::declval<T>(), std::declval<U>()))
|
||||||
|
operator()(T&& x, U&& y)
|
||||||
|
const SPROUT_NOEXCEPT_IF_EXPR(sprout::detail::div_at(std::declval<T>(), std::declval<U>()))
|
||||||
|
{
|
||||||
|
return sprout::detail::div_at(SPROUT_FORWARD(T, x), SPROUT_FORWARD(U, y));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
//
|
||||||
|
// container_traits
|
||||||
|
//
|
||||||
|
# define SPROUT_DETAIL_DIV_T_CONTAINER_TRAITS_IMPL(INT_T, DIV_T) \
|
||||||
|
template<> \
|
||||||
|
struct container_traits<DIV_T> \
|
||||||
|
: public sprout::detail::base_static_size<std::size_t, 2> \
|
||||||
|
{ \
|
||||||
|
public: \
|
||||||
|
typedef INT_T value_type; \
|
||||||
|
typedef sprout::index_iterator<DIV_T&, false, sprout::detail::div_at_f<> > iterator; \
|
||||||
|
typedef sprout::index_iterator<DIV_T const&, false, sprout::detail::div_at_f<> > const_iterator; \
|
||||||
|
typedef INT_T& reference; \
|
||||||
|
typedef INT_T const& const_reference; \
|
||||||
|
typedef std::size_t size_type; \
|
||||||
|
typedef std::ptrdiff_t difference_type; \
|
||||||
|
typedef INT_T* pointer; \
|
||||||
|
typedef INT_T const* const_pointer; \
|
||||||
|
typedef sprout::reverse_iterator<iterator> reverse_iterator; \
|
||||||
|
typedef sprout::reverse_iterator<const_iterator> const_reverse_iterator; \
|
||||||
|
}
|
||||||
|
|
||||||
|
SPROUT_DETAIL_DIV_T_CONTAINER_TRAITS_IMPL(int, sprout::div_t);
|
||||||
|
SPROUT_DETAIL_DIV_T_CONTAINER_TRAITS_IMPL(long, sprout::ldiv_t);
|
||||||
|
SPROUT_DETAIL_DIV_T_CONTAINER_TRAITS_IMPL(long long, sprout::lldiv_t);
|
||||||
|
|
||||||
|
//
|
||||||
|
// container_range_traits
|
||||||
|
//
|
||||||
|
# define SPROUT_DETAIL_DIV_T_CONTAINER_RANGE_TRAITS_IMPL(INT_T, DIV_T) \
|
||||||
|
template<> \
|
||||||
|
struct container_range_traits<DIV_T> { \
|
||||||
|
public: \
|
||||||
|
static SPROUT_CONSTEXPR typename sprout::container_traits<DIV_T>::iterator \
|
||||||
|
range_begin(DIV_T& t) { \
|
||||||
|
typedef typename sprout::container_traits<DIV_T>::iterator type; \
|
||||||
|
return type(t, 0); \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR typename sprout::container_traits<DIV_T const>::iterator \
|
||||||
|
range_begin(DIV_T const& t) { \
|
||||||
|
typedef typename sprout::container_traits<DIV_T const>::iterator type; \
|
||||||
|
return type(t, 0); \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR typename sprout::container_traits<DIV_T>::iterator \
|
||||||
|
range_end(DIV_T& t) { \
|
||||||
|
typedef typename sprout::container_traits<DIV_T>::iterator type; \
|
||||||
|
return type(t, 2); \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR typename sprout::container_traits<DIV_T const>::iterator \
|
||||||
|
range_end(DIV_T const& t) { \
|
||||||
|
typedef typename sprout::container_traits<DIV_T const>::iterator type; \
|
||||||
|
return type(t, 2); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
static SPROUT_CONSTEXPR typename sprout::container_traits<DIV_T>::size_type \
|
||||||
|
range_size(DIV_T const&) { \
|
||||||
|
return 2; \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR bool \
|
||||||
|
range_empty(DIV_T const&) { \
|
||||||
|
return false; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
static SPROUT_CONSTEXPR typename sprout::container_traits<DIV_T>::reference \
|
||||||
|
range_front(DIV_T& t) { \
|
||||||
|
return sprout::detail::div_at(t, 0); \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR typename sprout::container_traits<DIV_T const>::reference \
|
||||||
|
range_front(DIV_T const& t) { \
|
||||||
|
return sprout::detail::div_at(t, 0); \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR typename sprout::container_traits<DIV_T>::reference \
|
||||||
|
range_back(DIV_T& t) { \
|
||||||
|
return sprout::detail::div_at(t, 1); \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR typename sprout::container_traits<DIV_T const>::reference \
|
||||||
|
range_back(DIV_T const& t) { \
|
||||||
|
return sprout::detail::div_at(t, 1); \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR typename sprout::container_traits<DIV_T>::reference \
|
||||||
|
range_at(DIV_T& t, typename sprout::container_traits<DIV_T>::size_type i) { \
|
||||||
|
return sprout::detail::div_at(t, i); \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR typename sprout::container_traits<DIV_T const>::reference \
|
||||||
|
range_at(DIV_T const& t, typename sprout::container_traits<DIV_T const>::size_type i) { \
|
||||||
|
return sprout::detail::div_at(t, i); \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR typename sprout::container_traits<DIV_T>::iterator \
|
||||||
|
range_nth(DIV_T& t, typename sprout::container_traits<DIV_T>::size_type i) { \
|
||||||
|
typedef typename sprout::container_traits<DIV_T>::iterator type; \
|
||||||
|
return type(t, 0) + i; \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR typename sprout::container_traits<DIV_T const>::iterator \
|
||||||
|
range_nth(DIV_T const& t, typename sprout::container_traits<DIV_T const>::size_type i) { \
|
||||||
|
typedef typename sprout::container_traits<DIV_T const>::iterator type; \
|
||||||
|
return type(t, 0) + i; \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR typename sprout::container_traits<DIV_T>::size_type \
|
||||||
|
range_index_of(DIV_T& t, typename sprout::container_traits<DIV_T>::iterator p) { \
|
||||||
|
typedef typename sprout::container_traits<DIV_T>::iterator type; \
|
||||||
|
return sprout::distance(type(t, 0), p); \
|
||||||
|
} \
|
||||||
|
static SPROUT_CONSTEXPR typename sprout::container_traits<DIV_T const>::size_type \
|
||||||
|
range_index_of(DIV_T const& t, typename sprout::container_traits<DIV_T const>::iterator p) { \
|
||||||
|
typedef typename sprout::container_traits<DIV_T const>::iterator type; \
|
||||||
|
return sprout::distance(type(t, 0), p); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
SPROUT_DETAIL_DIV_T_CONTAINER_RANGE_TRAITS_IMPL(int, sprout::div_t);
|
||||||
|
SPROUT_DETAIL_DIV_T_CONTAINER_RANGE_TRAITS_IMPL(long, sprout::ldiv_t);
|
||||||
|
SPROUT_DETAIL_DIV_T_CONTAINER_RANGE_TRAITS_IMPL(long long, sprout::lldiv_t);
|
||||||
|
|
||||||
|
//
|
||||||
|
// container_construct_traits
|
||||||
|
//
|
||||||
|
# define SPROUT_DETAIL_DIV_T_CONTAINER_CONSTRUCT_TRAITS_IMPL(INT_T, DIV_T) \
|
||||||
|
template<> \
|
||||||
|
struct container_construct_traits<DIV_T> { \
|
||||||
|
public: \
|
||||||
|
typedef DIV_T copied_type; \
|
||||||
|
public: \
|
||||||
|
template<typename Cont> \
|
||||||
|
static SPROUT_CONSTEXPR copied_type \
|
||||||
|
deep_copy(Cont&& cont) { \
|
||||||
|
return SPROUT_FORWARD(Cont, cont); \
|
||||||
|
} \
|
||||||
|
template<typename... Args> \
|
||||||
|
static SPROUT_CONSTEXPR copied_type \
|
||||||
|
make(Args&&... args) { \
|
||||||
|
return sprout::detail::div_impl<INT_T>(SPROUT_FORWARD(Args, args)...); \
|
||||||
|
} \
|
||||||
|
template<typename Cont, typename... Args> \
|
||||||
|
static SPROUT_CONSTEXPR copied_type \
|
||||||
|
remake(Cont&&, typename sprout::container_traits<DIV_T>::difference_type size, Args&&... args) { \
|
||||||
|
return sprout::detail::div_impl<INT_T>(SPROUT_FORWARD(Args, args)...); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
SPROUT_DETAIL_DIV_T_CONTAINER_CONSTRUCT_TRAITS_IMPL(int, sprout::div_t);
|
||||||
|
SPROUT_DETAIL_DIV_T_CONTAINER_CONSTRUCT_TRAITS_IMPL(long, sprout::ldiv_t);
|
||||||
|
SPROUT_DETAIL_DIV_T_CONTAINER_CONSTRUCT_TRAITS_IMPL(long long, sprout::lldiv_t);
|
||||||
|
|
||||||
|
//
|
||||||
|
// container_transform_traits
|
||||||
|
//
|
||||||
|
# define SPROUT_DETAIL_DIV_T_CONTAINER_TRANSFORM_TRAITS_IMPL(INT_T, DIV_T) \
|
||||||
|
template<> \
|
||||||
|
struct container_transform_traits<DIV_T> { \
|
||||||
|
public: \
|
||||||
|
template<typename Type> \
|
||||||
|
struct rebind_type { \
|
||||||
|
public: \
|
||||||
|
typedef typename sprout::detail::div_t_traits<Type>::type type; \
|
||||||
|
}; \
|
||||||
|
}
|
||||||
|
|
||||||
|
SPROUT_DETAIL_DIV_T_CONTAINER_TRANSFORM_TRAITS_IMPL(int, sprout::div_t);
|
||||||
|
SPROUT_DETAIL_DIV_T_CONTAINER_TRANSFORM_TRAITS_IMPL(long, sprout::ldiv_t);
|
||||||
|
SPROUT_DETAIL_DIV_T_CONTAINER_TRANSFORM_TRAITS_IMPL(long long, sprout::lldiv_t);
|
||||||
|
} // namespace sprout
|
||||||
|
|
||||||
#endif // #ifndef SPROUT_CSTDLIB_DIV_HPP
|
#endif // #ifndef SPROUT_CSTDLIB_DIV_HPP
|
||||||
|
|
35
sprout/detail/static_size.hpp
Normal file
35
sprout/detail/static_size.hpp
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*=============================================================================
|
||||||
|
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_DETAIL_STATIC_SIZE_HPP
|
||||||
|
#define SPROUT_DETAIL_STATIC_SIZE_HPP
|
||||||
|
|
||||||
|
#include <sprout/config.hpp>
|
||||||
|
|
||||||
|
namespace sprout {
|
||||||
|
namespace detail {
|
||||||
|
template<typename T, T V>
|
||||||
|
struct base_static_size {
|
||||||
|
public:
|
||||||
|
SPROUT_STATIC_CONSTEXPR T static_size = V;
|
||||||
|
public:
|
||||||
|
static SPROUT_CONSTEXPR T
|
||||||
|
fixed_size() SPROUT_NOEXCEPT {
|
||||||
|
return static_size;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
template<typename T, T V>
|
||||||
|
SPROUT_CONSTEXPR_OR_CONST T sprout::detail::base_static_size<T, V>::static_size;
|
||||||
|
|
||||||
|
template<typename Container>
|
||||||
|
struct inherit_static_size
|
||||||
|
: public sprout::detail::base_static_size<typename Container::size_type, Container::static_size>
|
||||||
|
{};
|
||||||
|
} // namespace detail
|
||||||
|
} // namespace sprout
|
||||||
|
|
||||||
|
#endif // #ifndef SPROUT_DETAIL_STATIC_SIZE_HPP
|
|
@ -175,77 +175,77 @@ namespace sprout {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Container1, typename Container2, bool C>
|
template<typename Container1, typename Container2, bool C, typename Subscript>
|
||||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||||
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
|
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
|
||||||
bool
|
bool
|
||||||
>::type
|
>::type
|
||||||
operator==(sprout::index_iterator<Container1, C> const& lhs, sprout::index_iterator<Container2, C> const& rhs) {
|
operator==(sprout::index_iterator<Container1, C, Subscript> const& lhs, sprout::index_iterator<Container2, C, Subscript> const& rhs) {
|
||||||
return lhs.index() == rhs.index();
|
return lhs.index() == rhs.index();
|
||||||
}
|
}
|
||||||
template<typename Container1, typename Container2, bool C>
|
template<typename Container1, typename Container2, bool C, typename Subscript>
|
||||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||||
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
|
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
|
||||||
bool
|
bool
|
||||||
>::type
|
>::type
|
||||||
operator!=(sprout::index_iterator<Container1, C> const& lhs, sprout::index_iterator<Container2, C> const& rhs) {
|
operator!=(sprout::index_iterator<Container1, C, Subscript> const& lhs, sprout::index_iterator<Container2, C, Subscript> const& rhs) {
|
||||||
return !(lhs == rhs);
|
return !(lhs == rhs);
|
||||||
}
|
}
|
||||||
template<typename Container1, typename Container2, bool C>
|
template<typename Container1, typename Container2, bool C, typename Subscript>
|
||||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||||
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
|
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
|
||||||
bool
|
bool
|
||||||
>::type
|
>::type
|
||||||
operator<(sprout::index_iterator<Container1, C> const& lhs, sprout::index_iterator<Container2, C> const& rhs) {
|
operator<(sprout::index_iterator<Container1, C, Subscript> const& lhs, sprout::index_iterator<Container2, C, Subscript> const& rhs) {
|
||||||
return lhs.index() < rhs.index();
|
return lhs.index() < rhs.index();
|
||||||
}
|
}
|
||||||
template<typename Container1, typename Container2, bool C>
|
template<typename Container1, typename Container2, bool C, typename Subscript>
|
||||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||||
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
|
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
|
||||||
bool
|
bool
|
||||||
>::type
|
>::type
|
||||||
operator>(sprout::index_iterator<Container1, C> const& lhs, sprout::index_iterator<Container2, C> const& rhs) {
|
operator>(sprout::index_iterator<Container1, C, Subscript> const& lhs, sprout::index_iterator<Container2, C, Subscript> const& rhs) {
|
||||||
return rhs < lhs;
|
return rhs < lhs;
|
||||||
}
|
}
|
||||||
template<typename Container1, typename Container2, bool C>
|
template<typename Container1, typename Container2, bool C, typename Subscript>
|
||||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||||
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
|
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
|
||||||
bool
|
bool
|
||||||
>::type
|
>::type
|
||||||
operator<=(sprout::index_iterator<Container1, C> const& lhs, sprout::index_iterator<Container2, C> const& rhs) {
|
operator<=(sprout::index_iterator<Container1, C, Subscript> const& lhs, sprout::index_iterator<Container2, C, Subscript> const& rhs) {
|
||||||
return !(rhs < lhs);
|
return !(rhs < lhs);
|
||||||
}
|
}
|
||||||
template<typename Container1, typename Container2, bool C>
|
template<typename Container1, typename Container2, bool C, typename Subscript>
|
||||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||||
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
|
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
|
||||||
bool
|
bool
|
||||||
>::type
|
>::type
|
||||||
operator>=(sprout::index_iterator<Container1, C> const& lhs, sprout::index_iterator<Container2, C> const& rhs) {
|
operator>=(sprout::index_iterator<Container1, C, Subscript> const& lhs, sprout::index_iterator<Container2, C, Subscript> const& rhs) {
|
||||||
return !(lhs < rhs);
|
return !(lhs < rhs);
|
||||||
}
|
}
|
||||||
template<typename Container1, typename Container2, bool C>
|
template<typename Container1, typename Container2, bool C, typename Subscript>
|
||||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||||
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
|
std::is_same<typename std::decay<Container1>::type, typename std::decay<Container2>::type>::value,
|
||||||
decltype(
|
decltype(
|
||||||
std::declval<typename std::iterator_traits<sprout::index_iterator<Container1, C> >::difference_type>()
|
std::declval<typename std::iterator_traits<sprout::index_iterator<Container1, C, Subscript> >::difference_type>()
|
||||||
- std::declval<typename std::iterator_traits<sprout::index_iterator<Container2, C> >::difference_type>()
|
- std::declval<typename std::iterator_traits<sprout::index_iterator<Container2, C, Subscript> >::difference_type>()
|
||||||
)
|
)
|
||||||
>::type
|
>::type
|
||||||
operator-(sprout::index_iterator<Container1, C> const& lhs, sprout::index_iterator<Container2, C> const& rhs) {
|
operator-(sprout::index_iterator<Container1, C, Subscript> const& lhs, sprout::index_iterator<Container2, C, Subscript> const& rhs) {
|
||||||
return lhs.index() - rhs.index();
|
return lhs.index() - rhs.index();
|
||||||
}
|
}
|
||||||
template<typename Container, bool C>
|
template<typename Container, bool C, typename Subscript>
|
||||||
inline SPROUT_CONSTEXPR sprout::index_iterator<Container, C>
|
inline SPROUT_CONSTEXPR sprout::index_iterator<Container, C, Subscript>
|
||||||
operator+(typename sprout::index_iterator<Container, C>::difference_type n, sprout::index_iterator<Container, C> const& it) {
|
operator+(typename sprout::index_iterator<Container, C, Subscript>::difference_type n, sprout::index_iterator<Container, C, Subscript> const& it) {
|
||||||
return it + n;
|
return it + n;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// swap
|
// swap
|
||||||
//
|
//
|
||||||
template<typename Container, bool C>
|
template<typename Container, bool C, typename Subscript>
|
||||||
inline SPROUT_CXX14_CONSTEXPR void
|
inline SPROUT_CXX14_CONSTEXPR void
|
||||||
swap(sprout::index_iterator<Container, C>& lhs, sprout::index_iterator<Container, C>& rhs)
|
swap(sprout::index_iterator<Container, C, Subscript>& lhs, sprout::index_iterator<Container, C, Subscript>& rhs)
|
||||||
SPROUT_NOEXCEPT_IF_EXPR(lhs.swap(rhs))
|
SPROUT_NOEXCEPT_IF_EXPR(lhs.swap(rhs))
|
||||||
{
|
{
|
||||||
lhs.swap(rhs);
|
lhs.swap(rhs);
|
||||||
|
@ -266,34 +266,34 @@ namespace sprout {
|
||||||
struct is_index_iterator<T const volatile>
|
struct is_index_iterator<T const volatile>
|
||||||
: public sprout::is_index_iterator<T>
|
: public sprout::is_index_iterator<T>
|
||||||
{};
|
{};
|
||||||
template<typename Container, bool C>
|
template<typename Container, bool C, typename Subscript>
|
||||||
struct is_index_iterator<sprout::index_iterator<Container, C> >
|
struct is_index_iterator<sprout::index_iterator<Container, C, Subscript> >
|
||||||
: public sprout::true_type
|
: public sprout::true_type
|
||||||
{};
|
{};
|
||||||
|
|
||||||
//
|
//
|
||||||
// iterator_next
|
// iterator_next
|
||||||
//
|
//
|
||||||
template<typename Container, bool C>
|
template<typename Container, bool C, typename Subscript>
|
||||||
inline SPROUT_CONSTEXPR sprout::index_iterator<Container, C>
|
inline SPROUT_CONSTEXPR sprout::index_iterator<Container, C, Subscript>
|
||||||
iterator_next(sprout::index_iterator<Container, C> const& it) {
|
iterator_next(sprout::index_iterator<Container, C, Subscript> const& it) {
|
||||||
return it.next();
|
return it.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// iterator_prev
|
// iterator_prev
|
||||||
//
|
//
|
||||||
template<typename Container, bool C>
|
template<typename Container, bool C, typename Subscript>
|
||||||
inline SPROUT_CONSTEXPR sprout::index_iterator<Container, C>
|
inline SPROUT_CONSTEXPR sprout::index_iterator<Container, C, Subscript>
|
||||||
iterator_prev(sprout::index_iterator<Container, C> const& it) {
|
iterator_prev(sprout::index_iterator<Container, C, Subscript> const& it) {
|
||||||
return it.prev();
|
return it.prev();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// is_const_iterator_cast_convertible
|
// is_const_iterator_cast_convertible
|
||||||
//
|
//
|
||||||
template<typename FromContainer, typename ToContainer, bool C>
|
template<typename FromContainer, typename ToContainer, bool C, typename Subscript>
|
||||||
struct is_const_iterator_cast_convertible<sprout::index_iterator<FromContainer, C>, sprout::index_iterator<ToContainer, C> >
|
struct is_const_iterator_cast_convertible<sprout::index_iterator<FromContainer, C, Subscript>, sprout::index_iterator<ToContainer, C, Subscript> >
|
||||||
: public std::is_same<typename std::decay<FromContainer>::type, typename std::decay<ToContainer>::type>
|
: public std::is_same<typename std::decay<FromContainer>::type, typename std::decay<ToContainer>::type>
|
||||||
{};
|
{};
|
||||||
//
|
//
|
||||||
|
@ -301,11 +301,11 @@ namespace sprout {
|
||||||
//
|
//
|
||||||
template<
|
template<
|
||||||
typename T,
|
typename T,
|
||||||
typename Container, bool C,
|
typename Container, bool C, typename Subscript,
|
||||||
typename sprout::enabler_if<sprout::is_const_iterator_cast_convertible<sprout::index_iterator<Container, C>, T>::value>::type = sprout::enabler
|
typename sprout::enabler_if<sprout::is_const_iterator_cast_convertible<sprout::index_iterator<Container, C, Subscript>, T>::value>::type = sprout::enabler
|
||||||
>
|
>
|
||||||
inline SPROUT_CONSTEXPR T
|
inline SPROUT_CONSTEXPR T
|
||||||
const_iterator_conversion(sprout::index_iterator<Container, C> const& it) {
|
const_iterator_conversion(sprout::index_iterator<Container, C, Subscript> const& it) {
|
||||||
return T(const_cast<typename T::container_type>(it.base()), it.index());
|
return T(const_cast<typename T::container_type>(it.base()), it.index());
|
||||||
}
|
}
|
||||||
} // namespace sprout
|
} // namespace sprout
|
||||||
|
|
|
@ -15,23 +15,9 @@
|
||||||
#include <sprout/math/quaternion/detail/abs_max.hpp>
|
#include <sprout/math/quaternion/detail/abs_max.hpp>
|
||||||
#include <sprout/math/quaternion/detail/sum.hpp>
|
#include <sprout/math/quaternion/detail/sum.hpp>
|
||||||
#include <sprout/math/quaternion/detail/mul.hpp>
|
#include <sprout/math/quaternion/detail/mul.hpp>
|
||||||
|
#include <sprout/detail/static_size.hpp>
|
||||||
|
|
||||||
namespace sprout {
|
namespace sprout {
|
||||||
namespace detail {
|
|
||||||
template<typename T, T V>
|
|
||||||
struct base_static_size {
|
|
||||||
public:
|
|
||||||
SPROUT_STATIC_CONSTEXPR T static_size = V;
|
|
||||||
};
|
|
||||||
template<typename T, T V>
|
|
||||||
SPROUT_CONSTEXPR_OR_CONST T sprout::detail::base_static_size<T, V>::static_size;
|
|
||||||
|
|
||||||
template<typename Container>
|
|
||||||
struct inherit_static_size
|
|
||||||
: public sprout::detail::base_static_size<typename Container::size_type, Container::static_size>
|
|
||||||
{};
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
namespace math {
|
namespace math {
|
||||||
|
|
||||||
#define SPROUT_QUATERNION_ACCESSOR_GENERATOR(type) \
|
#define SPROUT_QUATERNION_ACCESSOR_GENERATOR(type) \
|
||||||
|
|
Loading…
Add table
Reference in a new issue