mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-01-21 20:36:37 +00:00
fix adapt interface: container, tuple, hash, generator
This commit is contained in:
parent
61720b72c3
commit
74e0c8acd6
36 changed files with 970 additions and 1056 deletions
|
@ -1,9 +1,9 @@
|
|||
#ifndef SPROUT_ADAPT_SSCRISK_CEL_UTILITY_HPP
|
||||
#define SPROUT_ADAPT_SSCRISK_CEL_UTILITY_HPP
|
||||
#ifndef SPROUT_ADAPT_STD_UTILITY_HPP
|
||||
#define SPROUT_ADAPT_STD_UTILITY_HPP
|
||||
|
||||
#include <utility>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/functional/hash/std/utility.hpp>
|
||||
#include <sprout/tuple/std/utility.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_ADAPT_SSCRISK_CEL_UTILITY_HPP
|
||||
#endif // #ifndef SPROUT_ADAPT_STD_UTILITY_HPP
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/container/container_traits.hpp>
|
||||
#include <sprout/container/container_range_traits.hpp>
|
||||
#include <sprout/adl/not_found.hpp>
|
||||
|
||||
namespace sprout_adl {
|
||||
|
@ -13,56 +14,41 @@ namespace sprout_adl {
|
|||
namespace sprout {
|
||||
namespace container_detail {
|
||||
template<typename Container>
|
||||
inline typename sprout::container_traits<Container>::iterator
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
range_begin(Container& cont) {
|
||||
return cont.begin();
|
||||
return sprout::container_range_traits<Container>::range_begin(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::const_iterator
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
range_begin(Container const& cont) {
|
||||
return cont.begin();
|
||||
}
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
inline typename sprout::container_traits<T[N]>::iterator
|
||||
range_begin(T (& arr)[N]) {
|
||||
typedef typename sprout::container_traits<T[N]>::iterator iterator;
|
||||
return iterator(arr);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::const_iterator
|
||||
range_begin(T const (& arr)[N]) {
|
||||
typedef typename sprout::container_traits<T const[N]>::const_iterator iterator;
|
||||
return iterator(arr);
|
||||
return sprout::container_range_traits<Container>::range_begin(cont);
|
||||
}
|
||||
} // namespace container_detail
|
||||
} // namespace sprout
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// begin
|
||||
//
|
||||
template<typename Container>
|
||||
inline typename sprout::container_traits<Container>::iterator
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
begin(Container& cont) {
|
||||
using sprout::container_detail::range_begin;
|
||||
using sprout_adl::range_begin;
|
||||
return range_begin(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::const_iterator
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
begin(Container const& cont) {
|
||||
using sprout::container_detail::range_begin;
|
||||
using sprout_adl::range_begin;
|
||||
return range_begin(cont);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline typename sprout::container_traits<T[N]>::iterator
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T[N]>::iterator
|
||||
begin(T (& arr)[N]) {
|
||||
return sprout::container_detail::range_begin(arr);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::const_iterator
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::iterator
|
||||
begin(T const (& arr)[N]) {
|
||||
return sprout::container_detail::range_begin(arr);
|
||||
}
|
||||
|
@ -71,14 +57,14 @@ namespace sprout {
|
|||
// cbegin
|
||||
//
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::const_iterator
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
cbegin(Container const& cont) {
|
||||
using sprout::container_detail::range_begin;
|
||||
using sprout_adl::range_begin;
|
||||
return range_begin(cont);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::const_iterator
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::iterator
|
||||
cbegin(T const (& arr)[N]) {
|
||||
return sprout::container_detail::range_begin(arr);
|
||||
}
|
||||
|
|
87
sprout/container/container_range_traits.hpp
Normal file
87
sprout/container/container_range_traits.hpp
Normal file
|
@ -0,0 +1,87 @@
|
|||
#ifndef SPROUT_CONTAINER_CONTAINER_RANGE_TRAITS_HPP
|
||||
#define SPROUT_CONTAINER_CONTAINER_RANGE_TRAITS_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/container/container_traits.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// container_range_traits
|
||||
//
|
||||
template<typename Container>
|
||||
struct container_range_traits {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
range_begin(Container& cont) {
|
||||
return cont.begin();
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
range_begin(Container const& cont) {
|
||||
return cont.begin();
|
||||
}
|
||||
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
range_end(Container& cont) {
|
||||
return cont.end();
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
range_end(Container const& cont) {
|
||||
return cont.end();
|
||||
}
|
||||
};
|
||||
template<typename Container>
|
||||
struct container_range_traits<Container const> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
range_begin(Container const& cont) {
|
||||
return sprout::container_range_traits<Container>::range_begin(cont);
|
||||
}
|
||||
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
range_end(Container const& cont) {
|
||||
return sprout::container_range_traits<Container>::range_end(cont);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
struct container_range_traits<T[N]> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<T[N]>::iterator
|
||||
range_begin(T (& arr)[N]) {
|
||||
typedef typename sprout::container_traits<T[N]>::iterator type;
|
||||
return type(arr);
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::iterator
|
||||
range_begin(T const (& arr)[N]) {
|
||||
typedef typename sprout::container_traits<T const[N]>::iterator type;
|
||||
return type(arr);
|
||||
}
|
||||
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<T[N]>::iterator
|
||||
range_end(T (& arr)[N]) {
|
||||
typedef typename sprout::container_traits<T[N]>::iterator type;
|
||||
return type(arr) + N;
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::iterator
|
||||
range_end(T const (& arr)[N]) {
|
||||
typedef typename sprout::container_traits<T const[N]>::iterator type;
|
||||
return type(arr) + N;
|
||||
}
|
||||
};
|
||||
template<typename T, std::size_t N>
|
||||
struct container_range_traits<T const[N]> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::iterator
|
||||
range_begin(T const (& arr)[N]) {
|
||||
return sprout::container_range_traits<T[N]>::range_begin(arr);
|
||||
}
|
||||
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::const_iterator
|
||||
range_end(T const (& arr)[N]) {
|
||||
return sprout::container_range_traits<T[N]>::range_end(arr);
|
||||
}
|
||||
};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_CONTAINER_CONTAINER_RANGE_TRAITS_HPP
|
|
@ -4,6 +4,7 @@
|
|||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/container/container_traits.hpp>
|
||||
#include <sprout/container/container_range_traits.hpp>
|
||||
#include <sprout/adl/not_found.hpp>
|
||||
|
||||
namespace sprout_adl {
|
||||
|
@ -13,56 +14,41 @@ namespace sprout_adl {
|
|||
namespace sprout {
|
||||
namespace container_detail {
|
||||
template<typename Container>
|
||||
inline typename sprout::container_traits<Container>::iterator
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
range_end(Container& cont) {
|
||||
return cont.end();
|
||||
return sprout::container_range_traits<Container>::range_end(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::const_iterator
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
range_end(Container const& cont) {
|
||||
return cont.end();
|
||||
}
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
inline typename sprout::container_traits<T[N]>::iterator
|
||||
range_end(T (& arr)[N]) {
|
||||
typedef typename sprout::container_traits<T[N]>::iterator iterator;
|
||||
return iterator(arr) + N;
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::const_iterator
|
||||
range_end(T const (& arr)[N]) {
|
||||
typedef typename sprout::container_traits<T const[N]>::const_iterator iterator;
|
||||
return iterator(arr) + N;
|
||||
return sprout::container_range_traits<Container>::range_end(cont);
|
||||
}
|
||||
} // namespace container_detail
|
||||
} // namespace sprout
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// end
|
||||
//
|
||||
template<typename Container>
|
||||
inline typename sprout::container_traits<Container>::iterator
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
end(Container& cont) {
|
||||
using sprout::container_detail::range_end;
|
||||
using sprout_adl::range_end;
|
||||
return range_end(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::const_iterator
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
end(Container const& cont) {
|
||||
using sprout::container_detail::range_end;
|
||||
using sprout_adl::range_end;
|
||||
return range_end(cont);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline typename sprout::container_traits<T[N]>::iterator
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T[N]>::iterator
|
||||
end(T (& arr)[N]) {
|
||||
return sprout::container_detail::range_end(arr);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::const_iterator
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::iterator
|
||||
end(T const (& arr)[N]) {
|
||||
return sprout::container_detail::range_end(arr);
|
||||
}
|
||||
|
@ -71,14 +57,14 @@ namespace sprout {
|
|||
// cend
|
||||
//
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::const_iterator
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
cend(Container const& cont) {
|
||||
using sprout::container_detail::range_end;
|
||||
using sprout_adl::range_end;
|
||||
return range_end(cont);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::const_iterator
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<T const[N]>::iterator
|
||||
cend(T const (& arr)[N]) {
|
||||
return sprout::container_detail::range_end(arr);
|
||||
}
|
||||
|
|
|
@ -23,36 +23,31 @@ namespace sprout {
|
|||
typedef sprout::index_iterator<sscrisk::cel::array<T, N>&, true> iterator;
|
||||
typedef sprout::index_iterator<sscrisk::cel::array<T, N> const&, true> const_iterator;
|
||||
};
|
||||
} // namespace sprout
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// range_begin
|
||||
// container_range_traits
|
||||
//
|
||||
template<typename T, std::size_t N>
|
||||
inline typename sprout::container_traits<sscrisk::cel::array<T, N> >::iterator
|
||||
range_begin(sscrisk::cel::array<T, N>& cont) {
|
||||
return typename sprout::container_traits<sscrisk::cel::array<T, N> >::iterator(cont, 0);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<sscrisk::cel::array<T, N> >::const_iterator
|
||||
range_begin(sscrisk::cel::array<T, N> const& cont) {
|
||||
return typename sprout::container_traits<sscrisk::cel::array<T, N> >::const_iterator(cont, 0);
|
||||
}
|
||||
struct container_range_traits<sscrisk::cel::array<T, N> > {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<sscrisk::cel::array<T, N> >::iterator
|
||||
range_begin(sscrisk::cel::array<T, N>& cont) {
|
||||
return typename sprout::container_traits<sscrisk::cel::array<T, N> >::iterator(cont, 0);
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<sscrisk::cel::array<T, N> const>::iterator
|
||||
range_begin(sscrisk::cel::array<T, N> const& cont) {
|
||||
return typename sprout::container_traits<sscrisk::cel::array<T, N> const>::iterator(cont, 0);
|
||||
}
|
||||
|
||||
//
|
||||
// range_end
|
||||
//
|
||||
template<typename T, std::size_t N>
|
||||
inline typename sprout::container_traits<sscrisk::cel::array<T, N> >::iterator
|
||||
range_end(sscrisk::cel::array<T, N>& cont) {
|
||||
return typename sprout::container_traits<sscrisk::cel::array<T, N> >::iterator(cont, cont.size());
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<sscrisk::cel::array<T, N> >::const_iterator
|
||||
range_end(sscrisk::cel::array<T, N> const& cont) {
|
||||
return typename sprout::container_traits<sscrisk::cel::array<T, N> >::const_iterator(cont, cont.size());
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<sscrisk::cel::array<T, N> >::iterator
|
||||
range_end(sscrisk::cel::array<T, N>& cont) {
|
||||
return typename sprout::container_traits<sscrisk::cel::array<T, N> >::iterator(cont, cont.size());
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<sscrisk::cel::array<T, N> const>::iterator
|
||||
range_end(sscrisk::cel::array<T, N> const& cont) {
|
||||
return typename sprout::container_traits<sscrisk::cel::array<T, N> const>::iterator(cont, cont.size());
|
||||
}
|
||||
};
|
||||
} // namespace sprout
|
||||
#endif
|
||||
|
||||
|
|
|
@ -23,36 +23,31 @@ namespace sprout {
|
|||
typedef sprout::index_iterator<std::array<T, N>&, true> iterator;
|
||||
typedef sprout::index_iterator<std::array<T, N> const&, true> const_iterator;
|
||||
};
|
||||
} // namespace sprout
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// range_begin
|
||||
// container_range_traits
|
||||
//
|
||||
template<typename T, std::size_t N>
|
||||
inline typename sprout::container_traits<std::array<T, N> >::iterator
|
||||
range_begin(std::array<T, N>& cont) {
|
||||
return typename sprout::container_traits<std::array<T, N> >::iterator(cont, 0);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<std::array<T, N> >::const_iterator
|
||||
range_begin(std::array<T, N> const& cont) {
|
||||
return typename sprout::container_traits<std::array<T, N> >::const_iterator(cont, 0);
|
||||
}
|
||||
struct container_range_traits<std::array<T, N> > {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<std::array<T, N> >::iterator
|
||||
range_begin(std::array<T, N>& cont) {
|
||||
return typename sprout::container_traits<std::array<T, N> >::iterator(cont, 0);
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<std::array<T, N> const>::iterator
|
||||
range_begin(std::array<T, N> const& cont) {
|
||||
return typename sprout::container_traits<std::array<T, N> const>::iterator(cont, 0);
|
||||
}
|
||||
|
||||
//
|
||||
// range_end
|
||||
//
|
||||
template<typename T, std::size_t N>
|
||||
inline typename sprout::container_traits<std::array<T, N> >::iterator
|
||||
range_end(std::array<T, N>& cont) {
|
||||
return typename sprout::container_traits<std::array<T, N> >::iterator(cont, cont.size());
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<std::array<T, N> >::const_iterator
|
||||
range_end(std::array<T, N> const& cont) {
|
||||
return typename sprout::container_traits<std::array<T, N> >::const_iterator(cont, cont.size());
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<std::array<T, N> >::iterator
|
||||
range_end(std::array<T, N>& cont) {
|
||||
return typename sprout::container_traits<std::array<T, N> >::iterator(cont, cont.size());
|
||||
}
|
||||
static SPROUT_CONSTEXPR typename sprout::container_traits<std::array<T, N> const>::iterator
|
||||
range_end(std::array<T, N> const& cont) {
|
||||
return typename sprout::container_traits<std::array<T, N> const>::iterator(cont, cont.size());
|
||||
}
|
||||
};
|
||||
} // namespace sprout
|
||||
#endif
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/container/container_traits.hpp>
|
||||
#include <sprout/container/container_range_traits.hpp>
|
||||
#include <sprout/container/container_construct_traits.hpp>
|
||||
#include <sprout/container/container_transform_traits.hpp>
|
||||
#include <sprout/container/container_fitness_traits.hpp>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <cstdint>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/math/floor.hpp>
|
||||
#include <sprout/utility/value_holder/value_holder.hpp>
|
||||
#include <sprout/utility/value_holder.hpp>
|
||||
#include <sprout/darkroom/materials/interpolation.hpp>
|
||||
|
||||
namespace sprout {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/array/array.hpp>
|
||||
#include <sprout/array.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
#include <sprout/tuple/functions.hpp>
|
||||
#include <sprout/darkroom/access/access.hpp>
|
||||
|
|
|
@ -172,7 +172,7 @@ namespace sprout {
|
|||
ray,
|
||||
det_sq > 0,
|
||||
b,
|
||||
sprout::sqrt(det_sq)
|
||||
det_sq > 0 ? sprout::sqrt(det_sq) : unit_type(0)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/index_tuple/metafunction.hpp>
|
||||
#include <sprout/array/array.hpp>
|
||||
#include <sprout/array.hpp>
|
||||
#include <sprout/container/traits.hpp>
|
||||
#include <sprout/container/functions.hpp>
|
||||
#include <sprout/container/indexes.hpp>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <cstddef>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/array/array.hpp>
|
||||
#include <sprout/array.hpp>
|
||||
#include <sprout/darkroom/access/access.hpp>
|
||||
#include <sprout/darkroom/colors/rgb.hpp>
|
||||
|
||||
|
|
|
@ -415,7 +415,7 @@ namespace sprout {
|
|||
typename enable_if_void<Res>::type = 0
|
||||
)
|
||||
{
|
||||
f_(sprout::detail::mu<BoundArgs>()(get<Indexes>(bound_args_), args)...);
|
||||
f_(sprout::detail::mu<BoundArgs>()(sprout::tuples::get<Indexes>(bound_args_), args)...);
|
||||
}
|
||||
template<typename Res, typename... Args, sprout::index_t... Indexes>
|
||||
SPROUT_CONSTEXPR Result call(
|
||||
|
|
|
@ -9,5 +9,6 @@
|
|||
#include <sprout/functional/hash/hash_combine.hpp>
|
||||
#include <sprout/functional/hash/hash_values.hpp>
|
||||
#include <sprout/functional/hash/hash_range.hpp>
|
||||
#include <sprout/functional/hash/hash_value_traits.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_HASH_HPP
|
||||
|
|
|
@ -15,7 +15,14 @@ namespace sprout {
|
|||
// to_hash
|
||||
//
|
||||
template<typename T>
|
||||
SPROUT_CONSTEXPR std::size_t to_hash(T const& v);
|
||||
SPROUT_CONSTEXPR std::size_t to_hash(T&& v);
|
||||
|
||||
//
|
||||
// hash_value
|
||||
//
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(T const& v);
|
||||
|
||||
//
|
||||
// hash_combine
|
||||
|
@ -42,6 +49,12 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR std::size_t hash_range(std::size_t seed, InputRange const& rng);
|
||||
template<typename InputRange>
|
||||
SPROUT_CONSTEXPR std::size_t hash_range(InputRange const& rng);
|
||||
|
||||
//
|
||||
// hash_value_traits
|
||||
//
|
||||
template<typename T>
|
||||
struct hash_value_traits;
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_HASH_HASH_FWD_HPP
|
||||
|
|
|
@ -2,150 +2,20 @@
|
|||
#define SPROUT_FUNCTIONAL_HASH_HASH_VALUE_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/functional/hash/hash_fwd.hpp>
|
||||
#include <sprout/functional/hash/detail/hash_float.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace hash_detail {
|
||||
template <typename T>
|
||||
struct is_basic_number
|
||||
: public std::integral_constant<
|
||||
bool,
|
||||
std::is_integral<T>::value
|
||||
&& (sizeof(T) <= sizeof(std::size_t))
|
||||
>
|
||||
{};
|
||||
template <typename T>
|
||||
struct is_long_number
|
||||
: public std::integral_constant<
|
||||
bool,
|
||||
std::is_integral<T>::value
|
||||
&& (sizeof(T) > sizeof(std::size_t))
|
||||
&& std::is_signed<T>::value
|
||||
>
|
||||
{};
|
||||
template <typename T>
|
||||
struct is_ulong_number
|
||||
: public std::integral_constant<
|
||||
bool,
|
||||
std::is_integral<T>::value
|
||||
&& (sizeof(T) > sizeof(std::size_t))
|
||||
&& std::is_unsigned<T>::value
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_signed_2(T val, int length, std::size_t seed, T positive, std::size_t i) {
|
||||
return i > 0
|
||||
? hash_value_signed_2(
|
||||
val,
|
||||
length,
|
||||
seed ^ static_cast<std::size_t>((positive >> i) + (seed << 6) + (seed >> 2)),
|
||||
positive,
|
||||
i - std::numeric_limits<std::size_t>::digits
|
||||
)
|
||||
: seed ^ static_cast<std::size_t>(val + (seed << 6) + (seed >> 2))
|
||||
;
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_signed_1(T val, int length, std::size_t seed, T positive) {
|
||||
return hash_value_signed_2(val, length, seed, positive, length * std::numeric_limits<std::size_t>::digits);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_signed(T val) {
|
||||
return sprout::hash_detail::hash_value_signed_1(
|
||||
val,
|
||||
(std::numeric_limits<T>::digits - 1) / std::numeric_limits<std::size_t>::digits,
|
||||
0,
|
||||
val < 0 ? -1 - val : val
|
||||
);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_unsigned_2(T val, int length, std::size_t seed, std::size_t i) {
|
||||
return i > 0
|
||||
? hash_value_unsigned_2(
|
||||
val,
|
||||
length,
|
||||
seed ^ static_cast<std::size_t>((val >> i) + (seed << 6) + (seed >> 2)),
|
||||
i - std::numeric_limits<std::size_t>::digits
|
||||
)
|
||||
: seed ^ static_cast<std::size_t>(val + (seed << 6) + (seed >> 2))
|
||||
;
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_unsigned_1(T val, int length, std::size_t seed) {
|
||||
return hash_value_unsigned_2(val, length, seed, length * std::numeric_limits<std::size_t>::digits);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_unsigned(T val) {
|
||||
return sprout::hash_detail::hash_value_unsigned_1(
|
||||
val,
|
||||
(std::numeric_limits<T>::digits - 1) / std::numeric_limits<std::size_t>::digits,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
inline std::size_t
|
||||
hash_value_pointer_1(std::size_t x) {
|
||||
return x + (x >> 3);
|
||||
}
|
||||
template<typename T>
|
||||
std::size_t
|
||||
hash_value_pointer(T const* v) {
|
||||
return sprout::hash_detail::hash_value_pointer_1(static_cast<std::size_t>(reinterpret_cast<std::ptrdiff_t>(v)));
|
||||
}
|
||||
} // namespace hash_detail
|
||||
|
||||
//
|
||||
// hash_value
|
||||
//
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::hash_detail::is_basic_number<T>::value, std::size_t>::type
|
||||
hash_value(T v) {
|
||||
return static_cast<std::size_t>(v);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::hash_detail::is_long_number<T>::value, std::size_t>::type
|
||||
hash_value(T v) {
|
||||
return sprout::hash_detail::hash_value_signed(v);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::hash_detail::is_ulong_number<T>::value, std::size_t>::type
|
||||
hash_value(T v) {
|
||||
return sprout::hash_detail::hash_value_unsigned(v);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<std::is_enum<T>::value, std::size_t>::type
|
||||
hash_value(T v) {
|
||||
return sprout::hash_value(static_cast<typename std::underlying_type<T>::type>(v));
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<std::is_floating_point<T>::value, std::size_t>::type
|
||||
hash_value(T v) {
|
||||
return sprout::detail::float_hash_value(v);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<std::is_pointer<typename std::remove_reference<T>::type>::value, std::size_t>::type
|
||||
hash_value(T&& v) {
|
||||
return sprout::hash_detail::hash_value_pointer(v);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(T const (&v)[N]) {
|
||||
return sprout::hash_range(v);
|
||||
hash_value(T const& v) {
|
||||
return sprout::hash_value_traits<T>::hash_value(v);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#include <sprout/functional/hash/hash_range.hpp>
|
||||
#include <sprout/functional/hash/hash_value_traits.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_HASH_HASH_VALUE_HPP
|
||||
|
|
181
sprout/functional/hash/hash_value_traits.hpp
Normal file
181
sprout/functional/hash/hash_value_traits.hpp
Normal file
|
@ -0,0 +1,181 @@
|
|||
#ifndef SPROUT_FUNCTIONAL_HASH_HASH_VALUE_TRAITS_HPP
|
||||
#define SPROUT_FUNCTIONAL_HASH_HASH_VALUE_TRAITS_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <limits>
|
||||
#include <functional>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/functional/hash/hash_fwd.hpp>
|
||||
#include <sprout/functional/hash/detail/hash_float.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace hash_detail {
|
||||
template <typename T>
|
||||
struct is_basic_number
|
||||
: public std::integral_constant<
|
||||
bool,
|
||||
std::is_integral<T>::value
|
||||
&& (sizeof(T) <= sizeof(std::size_t))
|
||||
>
|
||||
{};
|
||||
template <typename T>
|
||||
struct is_long_number
|
||||
: public std::integral_constant<
|
||||
bool,
|
||||
std::is_integral<T>::value
|
||||
&& (sizeof(T) > sizeof(std::size_t))
|
||||
&& std::is_signed<T>::value
|
||||
>
|
||||
{};
|
||||
template <typename T>
|
||||
struct is_ulong_number
|
||||
: public std::integral_constant<
|
||||
bool,
|
||||
std::is_integral<T>::value
|
||||
&& (sizeof(T) > sizeof(std::size_t))
|
||||
&& std::is_unsigned<T>::value
|
||||
>
|
||||
{};
|
||||
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_signed_2(T val, int length, std::size_t seed, T positive, std::size_t i) {
|
||||
return i > 0
|
||||
? hash_value_signed_2(
|
||||
val,
|
||||
length,
|
||||
seed ^ static_cast<std::size_t>((positive >> i) + (seed << 6) + (seed >> 2)),
|
||||
positive,
|
||||
i - std::numeric_limits<std::size_t>::digits
|
||||
)
|
||||
: seed ^ static_cast<std::size_t>(val + (seed << 6) + (seed >> 2))
|
||||
;
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_signed_1(T val, int length, std::size_t seed, T positive) {
|
||||
return hash_value_signed_2(val, length, seed, positive, length * std::numeric_limits<std::size_t>::digits);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_signed(T val) {
|
||||
return sprout::hash_detail::hash_value_signed_1(
|
||||
val,
|
||||
(std::numeric_limits<T>::digits - 1) / std::numeric_limits<std::size_t>::digits,
|
||||
0,
|
||||
val < 0 ? -1 - val : val
|
||||
);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_unsigned_2(T val, int length, std::size_t seed, std::size_t i) {
|
||||
return i > 0
|
||||
? hash_value_unsigned_2(
|
||||
val,
|
||||
length,
|
||||
seed ^ static_cast<std::size_t>((val >> i) + (seed << 6) + (seed >> 2)),
|
||||
i - std::numeric_limits<std::size_t>::digits
|
||||
)
|
||||
: seed ^ static_cast<std::size_t>(val + (seed << 6) + (seed >> 2))
|
||||
;
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_unsigned_1(T val, int length, std::size_t seed) {
|
||||
return hash_value_unsigned_2(val, length, seed, length * std::numeric_limits<std::size_t>::digits);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_unsigned(T val) {
|
||||
return sprout::hash_detail::hash_value_unsigned_1(
|
||||
val,
|
||||
(std::numeric_limits<T>::digits - 1) / std::numeric_limits<std::size_t>::digits,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
inline std::size_t
|
||||
hash_value_pointer_1(std::size_t x) {
|
||||
return x + (x >> 3);
|
||||
}
|
||||
template<typename T>
|
||||
std::size_t
|
||||
hash_value_pointer(T const* v) {
|
||||
return sprout::hash_detail::hash_value_pointer_1(static_cast<std::size_t>(reinterpret_cast<std::ptrdiff_t>(v)));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::hash_detail::is_basic_number<T>::value, std::size_t>::type
|
||||
hash_value_impl(T v) {
|
||||
return static_cast<std::size_t>(v);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::hash_detail::is_long_number<T>::value, std::size_t>::type
|
||||
hash_value_impl(T v) {
|
||||
return sprout::hash_detail::hash_value_signed(v);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<sprout::hash_detail::is_ulong_number<T>::value, std::size_t>::type
|
||||
hash_value_impl(T v) {
|
||||
return sprout::hash_detail::hash_value_unsigned(v);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<std::is_enum<T>::value, std::size_t>::type
|
||||
hash_value_impl(T v) {
|
||||
return sprout::hash_detail::hash_value_impl(static_cast<typename std::underlying_type<T>::type>(v));
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<std::is_floating_point<T>::value, std::size_t>::type
|
||||
hash_value_impl(T v) {
|
||||
return sprout::detail::float_hash_value(v);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<std::is_pointer<typename std::remove_reference<T>::type>::value, std::size_t>::type
|
||||
hash_value_impl(T&& v) {
|
||||
return sprout::hash_detail::hash_value_pointer(v);
|
||||
}
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value_impl(T const (&v)[N]) {
|
||||
return sprout::hash_range(v);
|
||||
}
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!std::is_arithmetic<T>::value && !std::is_enum<T>::value && !std::is_pointer<T>::value,
|
||||
std::size_t
|
||||
>::type
|
||||
hash_value_impl(T const &v) {
|
||||
return std::hash<typename std::decay<T>::type>()(v);
|
||||
}
|
||||
} // namespace hash_detail
|
||||
|
||||
//
|
||||
// hash_value_traits
|
||||
//
|
||||
template<typename T>
|
||||
struct hash_value_traits {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(T const& v) {
|
||||
return sprout::hash_detail::hash_value_impl(v);
|
||||
}
|
||||
};
|
||||
template<typename T>
|
||||
struct hash_value_traits<T const>
|
||||
: public sprout::hash_value_traits<T>
|
||||
{};
|
||||
template<typename T>
|
||||
struct hash_value_traits<T volatile>
|
||||
: public sprout::hash_value_traits<T>
|
||||
{};
|
||||
template<typename T>
|
||||
struct hash_value_traits<T const volatile>
|
||||
: public sprout::hash_value_traits<T>
|
||||
{};
|
||||
} // namespace sprout
|
||||
|
||||
#include <sprout/functional/hash/hash_range.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_HASH_HASH_VALUE_TRAITS_HPP
|
|
@ -4,17 +4,21 @@
|
|||
#include <cstddef>
|
||||
#include <sscrisk/cel/array.hpp>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/functional/hash.hpp>
|
||||
#include <sprout/functional/hash/hash_value_traits.hpp>
|
||||
#include <sprout/functional/hash/hash_range.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// hash_value
|
||||
// hash_value_traits
|
||||
//
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(sscrisk::cel::array<T, N> const& v) {
|
||||
return sprout::hash_range(v);
|
||||
}
|
||||
struct hash_value_traits<sscrisk::cel::array<T, N> > {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(sscrisk::cel::array<T, N> const& v) {
|
||||
return sprout::hash_range(v);
|
||||
}
|
||||
};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_HASH_SSCRISK_CEL_ARRAY_HPP
|
||||
|
|
|
@ -4,17 +4,21 @@
|
|||
#include <cstddef>
|
||||
#include <sscrisk/cel/utility.hpp>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/functional/hash.hpp>
|
||||
#include <sprout/functional/hash/hash_value_traits.hpp>
|
||||
#include <sprout/functional/hash/hash_values.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// hash_value
|
||||
// hash_value_traits
|
||||
//
|
||||
template<typename T1, typename T2>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(sscrisk::cel::pair<T1, T2> const& v) {
|
||||
return sprout::hash_values(v.first, v.second);
|
||||
}
|
||||
struct hash_value_traits<sscrisk::cel::pair<T1, T2> > {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(sscrisk::cel::pair<T1, T2> const& v) {
|
||||
return sprout::hash_values(v.first, v.second);
|
||||
}
|
||||
};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_HASH_SSCRISK_CEL_UTILITY_HPP
|
||||
|
|
|
@ -4,17 +4,21 @@
|
|||
#include <cstddef>
|
||||
#include <array>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/functional/hash.hpp>
|
||||
#include <sprout/functional/hash/hash_value_traits.hpp>
|
||||
#include <sprout/functional/hash/hash_range.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// hash_value
|
||||
// hash_value_traits
|
||||
//
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(std::array<T, N> const& v) {
|
||||
return sprout::hash_range(v);
|
||||
}
|
||||
struct hash_value_traits<std::array<T, N> > {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(std::array<T, N> const& v) {
|
||||
return sprout::hash_range(v);
|
||||
}
|
||||
};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_HASH_STD_ARRAY_HPP
|
||||
|
|
|
@ -4,17 +4,21 @@
|
|||
#include <cstddef>
|
||||
#include <utility>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/functional/hash.hpp>
|
||||
#include <sprout/functional/hash/hash_value_traits.hpp>
|
||||
#include <sprout/functional/hash/hash_values.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// hash_value
|
||||
// hash_value_traits
|
||||
//
|
||||
template<typename T1, typename T2>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(std::pair<T1, T2> const& v) {
|
||||
return sprout::hash_values(v.first, v.second);
|
||||
}
|
||||
struct hash_value_traits<std::pair<T1, T2> > {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(std::pair<T1, T2> const& v) {
|
||||
return sprout::hash_values(v.first, v.second);
|
||||
}
|
||||
};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_HASH_STD_UTILITY_HPP
|
||||
|
|
|
@ -2,144 +2,28 @@
|
|||
#define SPROUT_FUNCTIONAL_HASH_TO_HASH_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/functional/hash/hash_fwd.hpp>
|
||||
#include <sprout/functional/hash/hash_value.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
#include <sprout/adl/not_found.hpp>
|
||||
|
||||
namespace sprout_adl {
|
||||
sprout::not_found_via_adl hash_value(...);
|
||||
} // namespace sprout_adl
|
||||
|
||||
namespace sprout_hash_detail {
|
||||
using sprout::hash_value;
|
||||
using sprout_adl::hash_value;
|
||||
|
||||
template<typename T>
|
||||
struct has_adl_hash_value_test {
|
||||
public:
|
||||
template<
|
||||
typename U = T,
|
||||
typename sprout::enabler_if<
|
||||
sprout::is_found_via_adl<decltype(hash_value(std::declval<U>()))>::value
|
||||
>::type = sprout::enabler
|
||||
>
|
||||
static std::true_type test(int);
|
||||
static std::false_type test(...);
|
||||
};
|
||||
#if defined(_MSC_VER)
|
||||
template<typename T, typename Base_ = decltype(sprout_hash_detail::has_adl_hash_value_test<T>::test(0))>
|
||||
struct has_adl_hash_value
|
||||
: public Base_
|
||||
{};
|
||||
#else
|
||||
template<typename T>
|
||||
struct has_adl_hash_value
|
||||
: public decltype(sprout_hash_detail::has_adl_hash_value_test<T>::test(0))
|
||||
{};
|
||||
#endif
|
||||
|
||||
template<typename T, typename Enable = void>
|
||||
struct select_adl_hash_value;
|
||||
template<typename T>
|
||||
struct select_adl_hash_value<
|
||||
T,
|
||||
typename std::enable_if<
|
||||
sprout_hash_detail::has_adl_hash_value<T>::value
|
||||
>::type
|
||||
>
|
||||
: public std::true_type
|
||||
{};
|
||||
template<typename T>
|
||||
struct select_adl_hash_value<
|
||||
T,
|
||||
typename std::enable_if<!(
|
||||
sprout_hash_detail::has_adl_hash_value<T>::value
|
||||
)>::type
|
||||
>
|
||||
: public std::false_type
|
||||
{};
|
||||
|
||||
template<typename T, typename Enable = void>
|
||||
struct select_std_hash;
|
||||
template<typename T>
|
||||
struct select_std_hash<
|
||||
T,
|
||||
typename std::enable_if<
|
||||
!sprout_hash_detail::has_adl_hash_value<T>::value
|
||||
>::type
|
||||
>
|
||||
: public std::true_type
|
||||
{};
|
||||
template<typename T>
|
||||
struct select_std_hash<
|
||||
T,
|
||||
typename std::enable_if<!(
|
||||
!sprout_hash_detail::has_adl_hash_value<T>::value
|
||||
)>::type
|
||||
>
|
||||
: public std::false_type
|
||||
{};
|
||||
|
||||
template<typename T, typename = void>
|
||||
struct noexcept_to_hash;
|
||||
template<typename T>
|
||||
struct noexcept_to_hash<T, typename std::enable_if<sprout_hash_detail::select_adl_hash_value<T>::value>::type>
|
||||
: public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(hash_value(std::declval<T>()), false)>
|
||||
{};
|
||||
template<typename T>
|
||||
struct noexcept_to_hash<T, typename std::enable_if<sprout_hash_detail::select_std_hash<T>::value>::type>
|
||||
: public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(std::hash<typename std::decay<T>::type>()(std::declval<T>()), false)>
|
||||
{};
|
||||
|
||||
template<typename T, typename = void>
|
||||
struct to_hash_result;
|
||||
template<typename T>
|
||||
struct to_hash_result<T, typename std::enable_if<sprout_hash_detail::select_adl_hash_value<T>::value>::type> {
|
||||
public:
|
||||
typedef decltype(hash_value(std::declval<T>())) type;
|
||||
};
|
||||
template<typename T>
|
||||
struct to_hash_result<T, typename std::enable_if<sprout_hash_detail::select_std_hash<T>::value>::type> {
|
||||
public:
|
||||
typedef decltype(std::hash<typename std::decay<T>::type>()(std::declval<T>())) type;
|
||||
};
|
||||
|
||||
template<
|
||||
typename T,
|
||||
typename sprout::enabler_if<sprout_hash_detail::select_adl_hash_value<T>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR typename sprout_hash_detail::to_hash_result<T>::type
|
||||
to_hash_impl(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR((sprout_hash_detail::noexcept_to_hash<T>::value))
|
||||
{
|
||||
return hash_value(sprout::forward<T>(t));
|
||||
}
|
||||
template<
|
||||
typename T,
|
||||
typename sprout::enabler_if<sprout_hash_detail::select_std_hash<T>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR typename sprout_hash_detail::to_hash_result<T>::type
|
||||
to_hash_impl(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR((sprout_hash_detail::noexcept_to_hash<T>::value))
|
||||
{
|
||||
return std::hash<typename std::decay<T>::type>()(sprout::forward<T>(t));
|
||||
}
|
||||
} // namespace sprout_hash_detail
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// to_hash
|
||||
//
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
to_hash(T const& v) {
|
||||
return sprout_hash_detail::to_hash_impl(v);
|
||||
to_hash(T&& v) {
|
||||
using sprout::hash_value;
|
||||
using sprout_adl::hash_value;
|
||||
return hash_value(sprout::forward<T>(v));
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#include <sprout/functional/hash/hash_value.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_FUNCTIONAL_HASH_TO_HASH_HPP
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
#define SPROUT_GENERATOR_HPP
|
||||
|
||||
#include <sprout/generator/functions.hpp>
|
||||
#include <sprout/generator/generator_access_traits.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_GENERATOR_HPP
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef SPROUT_GENERATOR_FUNCTIONS_HPP
|
||||
#define SPROUT_GENERATOR_FUNCTIONS_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/generator/generated_value.hpp>
|
||||
#include <sprout/generator/next_generator.hpp>
|
||||
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
#include <sprout/tuple/tuple/get.hpp>
|
||||
#include <sprout/generator/generator_access_traits.hpp>
|
||||
#include <sprout/adl/not_found.hpp>
|
||||
|
||||
namespace sprout_adl {
|
||||
|
@ -13,208 +13,56 @@ namespace sprout_adl {
|
|||
} // namespace sprout_adl
|
||||
|
||||
namespace sprout_generator_detail {
|
||||
using sprout::tuples::get;
|
||||
using sprout_adl::generated_value;
|
||||
|
||||
template<typename T>
|
||||
struct has_adl_generated_value_test {
|
||||
public:
|
||||
template<
|
||||
typename U = T,
|
||||
typename sprout::enabler_if<
|
||||
sprout::is_found_via_adl<decltype(generated_value(std::declval<U>()))>::value
|
||||
>::type = sprout::enabler
|
||||
>
|
||||
static std::true_type test(int);
|
||||
static std::false_type test(...);
|
||||
};
|
||||
#if defined(_MSC_VER)
|
||||
template<typename T, typename Base_ = decltype(sprout_generator_detail::has_adl_generated_value_test<T>::test(0))>
|
||||
struct has_adl_generated_value
|
||||
: public Base_
|
||||
{};
|
||||
#else
|
||||
template<typename T>
|
||||
struct has_adl_generated_value
|
||||
: public decltype(sprout_generator_detail::has_adl_generated_value_test<T>::test(0))
|
||||
{};
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
struct has_mem_generated_value_test {
|
||||
public:
|
||||
template<
|
||||
typename U = T,
|
||||
typename = decltype(std::declval<U>().generated_value())
|
||||
>
|
||||
static std::true_type test(int);
|
||||
static std::false_type test(...);
|
||||
};
|
||||
#if defined(_MSC_VER)
|
||||
template<typename T, typename Base_ = decltype(sprout_generator_detail::has_mem_generated_value_test<T>::test(0))>
|
||||
struct has_mem_generated_value
|
||||
: public Base_
|
||||
{};
|
||||
#else
|
||||
template<typename T>
|
||||
struct has_mem_generated_value
|
||||
: public decltype(sprout_generator_detail::has_mem_generated_value_test<T>::test(0))
|
||||
{};
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
struct has_get_generated_value_test {
|
||||
public:
|
||||
template<
|
||||
typename U = T,
|
||||
typename = decltype(get<0>(std::declval<U>()))
|
||||
>
|
||||
static std::true_type test(int);
|
||||
static std::false_type test(...);
|
||||
};
|
||||
#if defined(_MSC_VER)
|
||||
template<typename T, typename Base_ = decltype(sprout_generator_detail::has_get_generated_value_test<T>::test(0))>
|
||||
struct has_get_generated_value
|
||||
: public Base_
|
||||
{};
|
||||
#else
|
||||
template<typename T>
|
||||
struct has_get_generated_value
|
||||
: public decltype(sprout_generator_detail::has_get_generated_value_test<T>::test(0))
|
||||
{};
|
||||
#endif
|
||||
|
||||
template<typename T, typename Enable = void>
|
||||
struct select_adl_generated_value;
|
||||
template<typename T>
|
||||
struct select_adl_generated_value<
|
||||
T,
|
||||
typename std::enable_if<
|
||||
sprout_generator_detail::has_adl_generated_value<T>::value
|
||||
>::type
|
||||
>
|
||||
: public std::true_type
|
||||
{};
|
||||
template<typename T>
|
||||
struct select_adl_generated_value<
|
||||
T,
|
||||
typename std::enable_if<!(
|
||||
sprout_generator_detail::has_adl_generated_value<T>::value
|
||||
)>::type
|
||||
>
|
||||
: public std::false_type
|
||||
{};
|
||||
|
||||
template<typename T, typename Enable = void>
|
||||
struct select_mem_generated_value;
|
||||
template<typename T>
|
||||
struct select_mem_generated_value<
|
||||
T,
|
||||
typename std::enable_if<
|
||||
sprout_generator_detail::has_mem_generated_value<T>::value
|
||||
&& !sprout_generator_detail::has_adl_generated_value<T>::value
|
||||
>::type
|
||||
>
|
||||
: public std::true_type
|
||||
{};
|
||||
template<typename T>
|
||||
struct select_mem_generated_value<
|
||||
T,
|
||||
typename std::enable_if<!(
|
||||
sprout_generator_detail::has_mem_generated_value<T>::value
|
||||
&& !sprout_generator_detail::has_adl_generated_value<T>::value
|
||||
)>::type
|
||||
>
|
||||
: public std::false_type
|
||||
{};
|
||||
|
||||
template<typename T, typename Enable = void>
|
||||
struct select_get_generated_value;
|
||||
template<typename T>
|
||||
struct select_get_generated_value<
|
||||
T,
|
||||
typename std::enable_if<
|
||||
sprout_generator_detail::has_get_generated_value<T>::value
|
||||
&& !sprout_generator_detail::has_adl_generated_value<T>::value
|
||||
&& !sprout_generator_detail::has_mem_generated_value<T>::value
|
||||
>::type
|
||||
>
|
||||
: public std::true_type
|
||||
{};
|
||||
template<typename T>
|
||||
struct select_get_generated_value<
|
||||
T,
|
||||
typename std::enable_if<!(
|
||||
sprout_generator_detail::has_get_generated_value<T>::value
|
||||
&& !sprout_generator_detail::has_adl_generated_value<T>::value
|
||||
&& !sprout_generator_detail::has_mem_generated_value<T>::value
|
||||
)>::type
|
||||
>
|
||||
: public std::false_type
|
||||
{};
|
||||
|
||||
template<typename T, typename = void>
|
||||
struct noexcept_generated_value;
|
||||
template<typename T>
|
||||
struct noexcept_generated_value<T, typename std::enable_if<sprout_generator_detail::select_adl_generated_value<T>::value>::type>
|
||||
: public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(generated_value(std::declval<T>()), false)>
|
||||
{};
|
||||
template<typename T>
|
||||
struct noexcept_generated_value<T, typename std::enable_if<sprout_generator_detail::select_mem_generated_value<T>::value>::type>
|
||||
: public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(std::declval<T>().generated_value(), false)>
|
||||
{};
|
||||
template<typename T>
|
||||
struct noexcept_generated_value<T, typename std::enable_if<sprout_generator_detail::select_get_generated_value<T>::value>::type>
|
||||
: public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(get<0>(std::declval<T>()), false)>
|
||||
{};
|
||||
|
||||
template<typename T, typename = void>
|
||||
struct generated_value_result;
|
||||
template<typename T>
|
||||
struct generated_value_result<T, typename std::enable_if<sprout_generator_detail::select_adl_generated_value<T>::value>::type> {
|
||||
public:
|
||||
typedef decltype(generated_value(std::declval<T>())) type;
|
||||
};
|
||||
template<typename T>
|
||||
struct generated_value_result<T, typename std::enable_if<sprout_generator_detail::select_mem_generated_value<T>::value>::type> {
|
||||
public:
|
||||
typedef decltype(std::declval<T>().generated_value()) type;
|
||||
};
|
||||
template<typename T>
|
||||
struct generated_value_result<T, typename std::enable_if<sprout_generator_detail::select_get_generated_value<T>::value>::type> {
|
||||
public:
|
||||
typedef decltype(get<0>(std::declval<T>())) type;
|
||||
};
|
||||
template<typename Gen>
|
||||
inline SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits<Gen>::generated_value(std::declval<Gen&>()))
|
||||
generated_value(Gen& gen)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<Gen>::generated_value(std::declval<Gen&>())))
|
||||
{
|
||||
return sprout::generators::generator_access_traits<Gen>::generated_value(gen);
|
||||
}
|
||||
template<typename Gen>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!std::is_const<Gen>::value && !std::is_volatile<Gen>::value && !std::is_reference<Gen>::value,
|
||||
decltype(sprout::generators::generator_access_traits<typename std::remove_reference<Gen>::type>::generated_value(std::declval<Gen&&>()))
|
||||
>::type
|
||||
generated_value(Gen&& gen)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<typename std::remove_reference<Gen>::type>::generated_value(std::declval<Gen&&>())))
|
||||
{
|
||||
return sprout::generators::generator_access_traits<Gen>::generated_value(gen);
|
||||
}
|
||||
template<typename Gen>
|
||||
inline SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits<Gen const>::generated_value(std::declval<Gen const&>()))
|
||||
generated_value(Gen const& gen)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<Gen const>::generated_value(std::declval<Gen const&>())))
|
||||
{
|
||||
return sprout::generators::generator_access_traits<Gen const>::generated_value(gen);
|
||||
}
|
||||
|
||||
template<
|
||||
typename T,
|
||||
typename sprout::enabler_if<sprout_generator_detail::select_adl_generated_value<T>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR typename sprout_generator_detail::generated_value_result<T>::type
|
||||
generated_value_impl(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_generated_value<T>::value))
|
||||
template<typename Gen>
|
||||
inline SPROUT_CONSTEXPR decltype(generated_value(std::declval<Gen&>()))
|
||||
call_generated_value(Gen& gen)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(generated_value(std::declval<Gen&>())))
|
||||
{
|
||||
return generated_value(sprout::forward<T>(t));
|
||||
return generated_value(gen);
|
||||
}
|
||||
template<
|
||||
typename T,
|
||||
typename sprout::enabler_if<sprout_generator_detail::select_mem_generated_value<T>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR typename sprout_generator_detail::generated_value_result<T>::type
|
||||
generated_value_impl(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_generated_value<T>::value))
|
||||
template<typename Gen>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!std::is_const<Gen>::value && !std::is_volatile<Gen>::value && !std::is_reference<Gen>::value,
|
||||
decltype(generated_value(std::declval<Gen&&>()))
|
||||
>::type
|
||||
call_generated_value(Gen&& gen)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(generated_value(std::declval<Gen&&>())))
|
||||
{
|
||||
return sprout::forward<T>(t).generated_value();
|
||||
return generated_value(gen);
|
||||
}
|
||||
template<
|
||||
typename T,
|
||||
typename sprout::enabler_if<sprout_generator_detail::select_get_generated_value<T>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR typename sprout_generator_detail::generated_value_result<T>::type
|
||||
generated_value_impl(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_generated_value<T>::value))
|
||||
template<typename Gen>
|
||||
inline SPROUT_CONSTEXPR decltype(generated_value(std::declval<Gen const&>()))
|
||||
call_generated_value(Gen const& gen)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(generated_value(std::declval<Gen const&>())))
|
||||
{
|
||||
return get<0>(sprout::forward<T>(t));
|
||||
return generated_value(gen);
|
||||
}
|
||||
} // namespace sprout_generator_detail
|
||||
|
||||
|
@ -224,11 +72,11 @@ namespace sprout {
|
|||
// generated_value
|
||||
//
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename sprout_generator_detail::generated_value_result<T>::type
|
||||
inline SPROUT_CONSTEXPR decltype(sprout_generator_detail::call_generated_value(std::declval<T>()))
|
||||
generated_value(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_generated_value<T>::value))
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout_generator_detail::call_generated_value(std::declval<T>())))
|
||||
{
|
||||
return sprout_generator_detail::generated_value_impl(sprout::forward<T>(t));
|
||||
return sprout_generator_detail::call_generated_value(sprout::forward<T>(t));
|
||||
}
|
||||
} // namespace generators
|
||||
|
||||
|
|
192
sprout/generator/generator_access_traits.hpp
Normal file
192
sprout/generator/generator_access_traits.hpp
Normal file
|
@ -0,0 +1,192 @@
|
|||
#ifndef SPROUT_GENERATOR_GENERATOR_ACCESS_TRAITS_HPP
|
||||
#define SPROUT_GENERATOR_GENERATOR_ACCESS_TRAITS_HPP
|
||||
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/tuple/tuple.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace generators {
|
||||
namespace detail {
|
||||
template<typename T>
|
||||
struct has_mem_generated_value_test {
|
||||
public:
|
||||
template<
|
||||
typename U = T,
|
||||
typename = decltype(std::declval<U>().generated_value())
|
||||
>
|
||||
static std::true_type test(int);
|
||||
static std::false_type test(...);
|
||||
};
|
||||
#if defined(_MSC_VER)
|
||||
template<typename T, typename Base_ = decltype(sprout::generators::detail::has_mem_generated_value_test<T>::test(0))>
|
||||
struct has_mem_generated_value
|
||||
: public Base_
|
||||
{};
|
||||
#else
|
||||
template<typename T>
|
||||
struct has_mem_generated_value
|
||||
: public decltype(sprout::generators::detail::has_mem_generated_value_test<T>::test(0))
|
||||
{};
|
||||
#endif
|
||||
|
||||
template<typename Gen, typename = void>
|
||||
struct generator_access_traits_generated_value_impl;
|
||||
template<typename Gen>
|
||||
struct generator_access_traits_generated_value_impl<
|
||||
Gen,
|
||||
typename std::enable_if<sprout::generators::detail::has_mem_generated_value<Gen>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR decltype(std::declval<Gen&>().generated_value())
|
||||
generated_value(Gen& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<Gen&>().generated_value()))
|
||||
{
|
||||
return t.generated_value();
|
||||
}
|
||||
static SPROUT_CONSTEXPR decltype(std::declval<Gen&&>().generated_value())
|
||||
generated_value(Gen&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<Gen&&>().generated_value()))
|
||||
{
|
||||
return t.generated_value();
|
||||
}
|
||||
static SPROUT_CONSTEXPR decltype(std::declval<Gen const&>().generated_value())
|
||||
generated_value(Gen const& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<Gen const&>().generated_value()))
|
||||
{
|
||||
return t.generated_value();
|
||||
}
|
||||
};
|
||||
template<typename Gen>
|
||||
struct generator_access_traits_generated_value_impl<
|
||||
Gen,
|
||||
typename std::enable_if<!sprout::generators::detail::has_mem_generated_value<Gen>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR decltype(sprout::tuples::get<0>(std::declval<Gen&>()))
|
||||
generated_value(Gen& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<0>(std::declval<Gen&>())))
|
||||
{
|
||||
return sprout::tuples::get<0>(t);
|
||||
}
|
||||
static SPROUT_CONSTEXPR decltype(sprout::tuples::get<0>(std::declval<Gen&&>()))
|
||||
generated_value(Gen&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<0>(std::declval<Gen&>())))
|
||||
{
|
||||
return sprout::tuples::get<0>(t);
|
||||
}
|
||||
static SPROUT_CONSTEXPR decltype(sprout::tuples::get<0>(std::declval<Gen const&>()))
|
||||
generated_value(Gen const& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<0>(std::declval<Gen const&>())))
|
||||
{
|
||||
return sprout::tuples::get<0>(t);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct has_mem_next_generator_test {
|
||||
public:
|
||||
template<
|
||||
typename U = T,
|
||||
typename = decltype(std::declval<U>().next_generator())
|
||||
>
|
||||
static std::true_type test(int);
|
||||
static std::false_type test(...);
|
||||
};
|
||||
#if defined(_MSC_VER)
|
||||
template<typename T, typename Base_ = decltype(sprout::generators::detail::has_mem_next_generator_test<T>::test(0))>
|
||||
struct has_mem_next_generator
|
||||
: public Base_
|
||||
{};
|
||||
#else
|
||||
template<typename T>
|
||||
struct has_mem_next_generator
|
||||
: public decltype(sprout::generators::detail::has_mem_next_generator_test<T>::test(0))
|
||||
{};
|
||||
#endif
|
||||
|
||||
template<typename Gen, typename = void>
|
||||
struct generator_access_traits_next_generator_impl;
|
||||
template<typename Gen>
|
||||
struct generator_access_traits_next_generator_impl<
|
||||
Gen,
|
||||
typename std::enable_if<sprout::generators::detail::has_mem_next_generator<Gen>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR decltype(std::declval<Gen&>().next_generator())
|
||||
next_generator(Gen& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<Gen&>().next_generator()))
|
||||
{
|
||||
return t.next_generator();
|
||||
}
|
||||
static SPROUT_CONSTEXPR decltype(std::declval<Gen&&>().next_generator())
|
||||
next_generator(Gen&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<Gen&&>().next_generator()))
|
||||
{
|
||||
return t.next_generator();
|
||||
}
|
||||
static SPROUT_CONSTEXPR decltype(std::declval<Gen const&>().next_generator())
|
||||
next_generator(Gen const& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::declval<Gen const&>().next_generator()))
|
||||
{
|
||||
return t.next_generator();
|
||||
}
|
||||
};
|
||||
template<typename Gen>
|
||||
struct generator_access_traits_next_generator_impl<
|
||||
Gen,
|
||||
typename std::enable_if<!sprout::generators::detail::has_mem_next_generator<Gen>::value>::type
|
||||
> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR decltype(sprout::tuples::get<1>(std::declval<Gen&>()))
|
||||
next_generator(Gen& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<1>(std::declval<Gen&>())))
|
||||
{
|
||||
return sprout::tuples::get<1>(t);
|
||||
}
|
||||
static SPROUT_CONSTEXPR decltype(sprout::tuples::get<1>(std::declval<Gen&&>()))
|
||||
next_generator(Gen&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<1>(std::declval<Gen&>())))
|
||||
{
|
||||
return sprout::tuples::get<1>(t);
|
||||
}
|
||||
static SPROUT_CONSTEXPR decltype(sprout::tuples::get<1>(std::declval<Gen const&>()))
|
||||
next_generator(Gen const& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::get<1>(std::declval<Gen const&>())))
|
||||
{
|
||||
return sprout::tuples::get<1>(t);
|
||||
}
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
//
|
||||
// generator_access_traits
|
||||
//
|
||||
template<typename Gen>
|
||||
struct generator_access_traits
|
||||
: public sprout::generators::detail::generator_access_traits_generated_value_impl<Gen>
|
||||
, public sprout::generators::detail::generator_access_traits_next_generator_impl<Gen>
|
||||
{};
|
||||
template<typename Gen>
|
||||
struct generator_access_traits<Gen const> {
|
||||
public:
|
||||
static SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits<Gen>::generated_value(std::declval<Gen const&>()))
|
||||
generated_value(Gen const& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<Gen>::generated_value(std::declval<Gen const&>())))
|
||||
{
|
||||
return sprout::generators::generator_access_traits<Gen>::generated_value(t);
|
||||
}
|
||||
static SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits<Gen>::next_generator(std::declval<Gen const&>()))
|
||||
next_generator(Gen const& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<Gen>::next_generator(std::declval<Gen const&>())))
|
||||
{
|
||||
return sprout::generators::generator_access_traits<Gen>::next_generator(t);
|
||||
}
|
||||
};
|
||||
} // namespace generators
|
||||
|
||||
using sprout::generators::generator_access_traits;
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_GENERATOR_GENERATOR_ACCESS_TRAITS_HPP
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
#include <sprout/tuple/tuple/get.hpp>
|
||||
#include <sprout/generator/generator_access_traits.hpp>
|
||||
#include <sprout/adl/not_found.hpp>
|
||||
|
||||
namespace sprout_adl {
|
||||
|
@ -13,208 +13,56 @@ namespace sprout_adl {
|
|||
} // namespace sprout_adl
|
||||
|
||||
namespace sprout_generator_detail {
|
||||
using sprout::tuples::get;
|
||||
using sprout_adl::next_generator;
|
||||
|
||||
template<typename T>
|
||||
struct has_adl_next_generator_test {
|
||||
public:
|
||||
template<
|
||||
typename U = T,
|
||||
typename sprout::enabler_if<
|
||||
sprout::is_found_via_adl<decltype(next_generator(std::declval<U>()))>::value
|
||||
>::type = sprout::enabler
|
||||
>
|
||||
static std::true_type test(int);
|
||||
static std::false_type test(...);
|
||||
};
|
||||
#if defined(_MSC_VER)
|
||||
template<typename T, typename Base_ = decltype(sprout_generator_detail::has_adl_next_generator_test<T>::test(0))>
|
||||
struct has_adl_next_generator
|
||||
: public Base_
|
||||
{};
|
||||
#else
|
||||
template<typename T>
|
||||
struct has_adl_next_generator
|
||||
: public decltype(sprout_generator_detail::has_adl_next_generator_test<T>::test(0))
|
||||
{};
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
struct has_mem_next_generator_test {
|
||||
public:
|
||||
template<
|
||||
typename U = T,
|
||||
typename = decltype(std::declval<U>().next_generator())
|
||||
>
|
||||
static std::true_type test(int);
|
||||
static std::false_type test(...);
|
||||
};
|
||||
#if defined(_MSC_VER)
|
||||
template<typename T, typename Base_ = decltype(sprout_generator_detail::has_mem_next_generator_test<T>::test(0))>
|
||||
struct has_mem_next_generator
|
||||
: public Base_
|
||||
{};
|
||||
#else
|
||||
template<typename T>
|
||||
struct has_mem_next_generator
|
||||
: public decltype(sprout_generator_detail::has_mem_next_generator_test<T>::test(0))
|
||||
{};
|
||||
#endif
|
||||
|
||||
template<typename T>
|
||||
struct has_get_next_generator_test {
|
||||
public:
|
||||
template<
|
||||
typename U = T,
|
||||
typename = decltype(get<1>(std::declval<U>()))
|
||||
>
|
||||
static std::true_type test(int);
|
||||
static std::false_type test(...);
|
||||
};
|
||||
#if defined(_MSC_VER)
|
||||
template<typename T, typename Base_ = decltype(sprout_generator_detail::has_get_next_generator_test<T>::test(0))>
|
||||
struct has_get_next_generator
|
||||
: public Base_
|
||||
{};
|
||||
#else
|
||||
template<typename T>
|
||||
struct has_get_next_generator
|
||||
: public decltype(sprout_generator_detail::has_get_next_generator_test<T>::test(0))
|
||||
{};
|
||||
#endif
|
||||
|
||||
template<typename T, typename Enable = void>
|
||||
struct select_adl_next_generator;
|
||||
template<typename T>
|
||||
struct select_adl_next_generator<
|
||||
T,
|
||||
typename std::enable_if<
|
||||
sprout_generator_detail::has_adl_next_generator<T>::value
|
||||
>::type
|
||||
>
|
||||
: public std::true_type
|
||||
{};
|
||||
template<typename T>
|
||||
struct select_adl_next_generator<
|
||||
T,
|
||||
typename std::enable_if<!(
|
||||
sprout_generator_detail::has_adl_next_generator<T>::value
|
||||
)>::type
|
||||
>
|
||||
: public std::false_type
|
||||
{};
|
||||
|
||||
template<typename T, typename Enable = void>
|
||||
struct select_mem_next_generator;
|
||||
template<typename T>
|
||||
struct select_mem_next_generator<
|
||||
T,
|
||||
typename std::enable_if<
|
||||
sprout_generator_detail::has_mem_next_generator<T>::value
|
||||
&& !sprout_generator_detail::has_adl_next_generator<T>::value
|
||||
>::type
|
||||
>
|
||||
: public std::true_type
|
||||
{};
|
||||
template<typename T>
|
||||
struct select_mem_next_generator<
|
||||
T,
|
||||
typename std::enable_if<!(
|
||||
sprout_generator_detail::has_mem_next_generator<T>::value
|
||||
&& !sprout_generator_detail::has_adl_next_generator<T>::value
|
||||
)>::type
|
||||
>
|
||||
: public std::false_type
|
||||
{};
|
||||
|
||||
template<typename T, typename Enable = void>
|
||||
struct select_get_next_generator;
|
||||
template<typename T>
|
||||
struct select_get_next_generator<
|
||||
T,
|
||||
typename std::enable_if<
|
||||
sprout_generator_detail::has_get_next_generator<T>::value
|
||||
&& !sprout_generator_detail::has_adl_next_generator<T>::value
|
||||
&& !sprout_generator_detail::has_mem_next_generator<T>::value
|
||||
>::type
|
||||
>
|
||||
: public std::true_type
|
||||
{};
|
||||
template<typename T>
|
||||
struct select_get_next_generator<
|
||||
T,
|
||||
typename std::enable_if<!(
|
||||
sprout_generator_detail::has_get_next_generator<T>::value
|
||||
&& !sprout_generator_detail::has_adl_next_generator<T>::value
|
||||
&& !sprout_generator_detail::has_mem_next_generator<T>::value
|
||||
)>::type
|
||||
>
|
||||
: public std::false_type
|
||||
{};
|
||||
|
||||
template<typename T, typename = void>
|
||||
struct noexcept_next_generator;
|
||||
template<typename T>
|
||||
struct noexcept_next_generator<T, typename std::enable_if<sprout_generator_detail::select_adl_next_generator<T>::value>::type>
|
||||
: public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(next_generator(std::declval<T>()), false)>
|
||||
{};
|
||||
template<typename T>
|
||||
struct noexcept_next_generator<T, typename std::enable_if<sprout_generator_detail::select_mem_next_generator<T>::value>::type>
|
||||
: public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(std::declval<T>().next_generator(), false)>
|
||||
{};
|
||||
template<typename T>
|
||||
struct noexcept_next_generator<T, typename std::enable_if<sprout_generator_detail::select_get_next_generator<T>::value>::type>
|
||||
: public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(get<1>(std::declval<T>()), false)>
|
||||
{};
|
||||
|
||||
template<typename T, typename = void>
|
||||
struct next_generator_result;
|
||||
template<typename T>
|
||||
struct next_generator_result<T, typename std::enable_if<sprout_generator_detail::select_adl_next_generator<T>::value>::type> {
|
||||
public:
|
||||
typedef decltype(next_generator(std::declval<T>())) type;
|
||||
};
|
||||
template<typename T>
|
||||
struct next_generator_result<T, typename std::enable_if<sprout_generator_detail::select_mem_next_generator<T>::value>::type> {
|
||||
public:
|
||||
typedef decltype(std::declval<T>().next_generator()) type;
|
||||
};
|
||||
template<typename T>
|
||||
struct next_generator_result<T, typename std::enable_if<sprout_generator_detail::select_get_next_generator<T>::value>::type> {
|
||||
public:
|
||||
typedef decltype(get<1>(std::declval<T>())) type;
|
||||
};
|
||||
template<typename Gen>
|
||||
inline SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits<Gen>::next_generator(std::declval<Gen&>()))
|
||||
next_generator(Gen& gen)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<Gen>::next_generator(std::declval<Gen&>())))
|
||||
{
|
||||
return sprout::generators::generator_access_traits<Gen>::next_generator(gen);
|
||||
}
|
||||
template<typename Gen>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!std::is_const<Gen>::value && !std::is_volatile<Gen>::value && !std::is_reference<Gen>::value,
|
||||
decltype(sprout::generators::generator_access_traits<typename std::remove_reference<Gen>::type>::next_generator(std::declval<Gen&&>()))
|
||||
>::type
|
||||
next_generator(Gen&& gen)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<typename std::remove_reference<Gen>::type>::next_generator(std::declval<Gen&&>())))
|
||||
{
|
||||
return sprout::generators::generator_access_traits<Gen>::next_generator(gen);
|
||||
}
|
||||
template<typename Gen>
|
||||
inline SPROUT_CONSTEXPR decltype(sprout::generators::generator_access_traits<Gen const>::next_generator(std::declval<Gen const&>()))
|
||||
next_generator(Gen const& gen)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::generators::generator_access_traits<Gen const>::next_generator(std::declval<Gen const&>())))
|
||||
{
|
||||
return sprout::generators::generator_access_traits<Gen const>::next_generator(gen);
|
||||
}
|
||||
|
||||
template<
|
||||
typename T,
|
||||
typename sprout::enabler_if<sprout_generator_detail::select_adl_next_generator<T>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR typename sprout_generator_detail::next_generator_result<T>::type
|
||||
next_generator_impl(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_next_generator<T>::value))
|
||||
template<typename Gen>
|
||||
inline SPROUT_CONSTEXPR decltype(next_generator(std::declval<Gen&>()))
|
||||
call_next_generator(Gen& gen)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(next_generator(std::declval<Gen&>())))
|
||||
{
|
||||
return next_generator(sprout::forward<T>(t));
|
||||
return next_generator(gen);
|
||||
}
|
||||
template<
|
||||
typename T,
|
||||
typename sprout::enabler_if<sprout_generator_detail::select_mem_next_generator<T>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR typename sprout_generator_detail::next_generator_result<T>::type
|
||||
next_generator_impl(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_next_generator<T>::value))
|
||||
template<typename Gen>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!std::is_const<Gen>::value && !std::is_volatile<Gen>::value && !std::is_reference<Gen>::value,
|
||||
decltype(next_generator(std::declval<Gen&&>()))
|
||||
>::type
|
||||
call_next_generator(Gen&& gen)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(next_generator(std::declval<Gen&&>())))
|
||||
{
|
||||
return sprout::forward<T>(t).next_generator();
|
||||
return next_generator(gen);
|
||||
}
|
||||
template<
|
||||
typename T,
|
||||
typename sprout::enabler_if<sprout_generator_detail::select_get_next_generator<T>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR typename sprout_generator_detail::next_generator_result<T>::type
|
||||
next_generator_impl(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_next_generator<T>::value))
|
||||
template<typename Gen>
|
||||
inline SPROUT_CONSTEXPR decltype(next_generator(std::declval<Gen const&>()))
|
||||
call_next_generator(Gen const& gen)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(next_generator(std::declval<Gen const&>())))
|
||||
{
|
||||
return get<1>(sprout::forward<T>(t));
|
||||
return next_generator(gen);
|
||||
}
|
||||
} // namespace sprout_generator_detail
|
||||
|
||||
|
@ -224,11 +72,11 @@ namespace sprout {
|
|||
// next_generator
|
||||
//
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename sprout_generator_detail::next_generator_result<T>::type
|
||||
inline SPROUT_CONSTEXPR decltype(sprout_generator_detail::call_next_generator(std::declval<T>()))
|
||||
next_generator(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR((sprout_generator_detail::noexcept_next_generator<T>::value))
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout_generator_detail::call_next_generator(std::declval<T>())))
|
||||
{
|
||||
return sprout_generator_detail::next_generator_impl(sprout::forward<T>(t));
|
||||
return sprout_generator_detail::call_next_generator(sprout::forward<T>(t));
|
||||
}
|
||||
} // namespace generators
|
||||
|
||||
|
|
|
@ -6,29 +6,36 @@
|
|||
#include <sscrisk/cel/array.hpp>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/utility/move.hpp>
|
||||
#include <sprout/tuple/tuple/tuple_access_traits.hpp>
|
||||
#include <sprout/tuple/tuple/get.hpp>
|
||||
|
||||
namespace sprout_adl {
|
||||
//
|
||||
// tuple_get
|
||||
//
|
||||
template<std::size_t I, typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR T&
|
||||
tuple_get(sscrisk::cel::array<T, N>& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < N, "tuple_get: index out of range");
|
||||
return t[I];
|
||||
}
|
||||
template<std::size_t I, typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR T const&
|
||||
tuple_get(sscrisk::cel::array<T, N> const& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < N, "tuple_get: index out of range");
|
||||
return t[I];
|
||||
}
|
||||
template<std::size_t I, typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR T&&
|
||||
tuple_get(sscrisk::cel::array<T, N>&& t) SPROUT_NOEXCEPT {
|
||||
return sprout::move(sprout::tuples::get<I>(t));
|
||||
}
|
||||
} // namespace sprout_adl
|
||||
namespace sprout {
|
||||
namespace tuples {
|
||||
//
|
||||
// tuple_access_traits
|
||||
//
|
||||
template<typename T, std::size_t N>
|
||||
struct tuple_access_traits<sscrisk::cel::array<T, N> > {
|
||||
public:
|
||||
template<std::size_t I>
|
||||
static SPROUT_CONSTEXPR T&
|
||||
tuple_get(sscrisk::cel::array<T, N>& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < N, "tuple_get: index out of range");
|
||||
return t[I];
|
||||
}
|
||||
template<std::size_t I>
|
||||
static SPROUT_CONSTEXPR T const&
|
||||
tuple_get(sscrisk::cel::array<T, N> const& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < N, "tuple_get: index out of range");
|
||||
return t[I];
|
||||
}
|
||||
template<std::size_t I>
|
||||
static SPROUT_CONSTEXPR T&&
|
||||
tuple_get(sscrisk::cel::array<T, N>&& t) SPROUT_NOEXCEPT {
|
||||
return sprout::move(tuple_get<I>(t));
|
||||
}
|
||||
};
|
||||
} // namespace tuples
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_SSCRISK_CEL_ARRAY_HPP
|
||||
|
|
|
@ -68,27 +68,33 @@ namespace sprout {
|
|||
} // namespace tuples
|
||||
} // namespace sprout
|
||||
|
||||
namespace sprout_adl {
|
||||
//
|
||||
// tuple_get
|
||||
//
|
||||
template<std::size_t I, typename T1, typename T2>
|
||||
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sscrisk::cel::pair<T1, T2> >::type&
|
||||
tuple_get(sscrisk::cel::pair<T1, T2>& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < 2, "tuple_get: index out of range");
|
||||
return sprout::tuples::detail::get_impl<I, sscrisk::cel::pair<T1, T2> >()(t);
|
||||
}
|
||||
template<std::size_t I, typename T1, typename T2>
|
||||
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sscrisk::cel::pair<T1, T2> >::type const&
|
||||
tuple_get(sscrisk::cel::pair<T1, T2> const& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < 2, "tuple_get: index out of range");
|
||||
return sprout::tuples::detail::get_impl<I, sscrisk::cel::pair<T1, T2> >()(t);
|
||||
}
|
||||
template<std::size_t I, typename T1, typename T2>
|
||||
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sscrisk::cel::pair<T1, T2> >::type&&
|
||||
tuple_get(sscrisk::cel::pair<T1, T2>&& t) SPROUT_NOEXCEPT {
|
||||
return sprout::move(sprout::tuples::get<I>(t));
|
||||
}
|
||||
} // namespace sprout_adl
|
||||
namespace sprout {
|
||||
namespace tuples {
|
||||
//
|
||||
// tuple_access_traits
|
||||
//
|
||||
template<typename T1, typename T2>
|
||||
struct tuple_access_traits<sscrisk::cel::pair<T1, T2> > {
|
||||
public:
|
||||
template<std::size_t I>
|
||||
static SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sscrisk::cel::pair<T1, T2> >::type&
|
||||
tuple_get(sscrisk::cel::pair<T1, T2>& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < 2, "tuple_get: index out of range");
|
||||
return sprout::tuples::detail::get_impl<I, sscrisk::cel::pair<T1, T2> >()(t);
|
||||
}
|
||||
template<std::size_t I>
|
||||
static SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sscrisk::cel::pair<T1, T2> >::type const&
|
||||
tuple_get(sscrisk::cel::pair<T1, T2> const& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < 2, "tuple_get: index out of range");
|
||||
return sprout::tuples::detail::get_impl<I, sscrisk::cel::pair<T1, T2> >()(t);
|
||||
}
|
||||
template<std::size_t I>
|
||||
static SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sscrisk::cel::pair<T1, T2> >::type&&
|
||||
tuple_get(sscrisk::cel::pair<T1, T2>&& t) SPROUT_NOEXCEPT {
|
||||
return sprout::move(tuple_get<I>(t));
|
||||
}
|
||||
};
|
||||
} // namespace tuples
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_SSCRISK_CEL_UTILITY_HPP
|
||||
|
|
|
@ -6,29 +6,36 @@
|
|||
#include <array>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/utility/move.hpp>
|
||||
#include <sprout/tuple/tuple/tuple_access_traits.hpp>
|
||||
#include <sprout/tuple/tuple/get.hpp>
|
||||
|
||||
namespace sprout_adl {
|
||||
//
|
||||
// tuple_get
|
||||
//
|
||||
template<std::size_t I, typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR T&
|
||||
tuple_get(std::array<T, N>& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < N, "tuple_get: index out of range");
|
||||
return t[I];
|
||||
}
|
||||
template<std::size_t I, typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR T const&
|
||||
tuple_get(std::array<T, N> const& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < N, "tuple_get: index out of range");
|
||||
return t[I];
|
||||
}
|
||||
template<std::size_t I, typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR T&&
|
||||
tuple_get(std::array<T, N>&& t) SPROUT_NOEXCEPT {
|
||||
return sprout::move(sprout::tuples::get<I>(t));
|
||||
}
|
||||
} // namespace sprout_adl
|
||||
namespace sprout {
|
||||
namespace tuples {
|
||||
//
|
||||
// tuple_access_traits
|
||||
//
|
||||
template<typename T, std::size_t N>
|
||||
struct tuple_access_traits<std::array<T, N> > {
|
||||
public:
|
||||
template<std::size_t I>
|
||||
static SPROUT_CONSTEXPR T&
|
||||
tuple_get(std::array<T, N>& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < N, "tuple_get: index out of range");
|
||||
return t[I];
|
||||
}
|
||||
template<std::size_t I>
|
||||
static SPROUT_CONSTEXPR T const&
|
||||
tuple_get(std::array<T, N> const& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < N, "tuple_get: index out of range");
|
||||
return t[I];
|
||||
}
|
||||
template<std::size_t I>
|
||||
static SPROUT_CONSTEXPR T&&
|
||||
tuple_get(std::array<T, N>&& t) SPROUT_NOEXCEPT {
|
||||
return sprout::move(tuple_get<I>(t));
|
||||
}
|
||||
};
|
||||
} // namespace tuples
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_STD_ARRAY_HPP
|
||||
|
|
|
@ -38,27 +38,33 @@ namespace sprout {
|
|||
} // namespace tuples
|
||||
} // namespace sprout
|
||||
|
||||
namespace sprout_adl {
|
||||
//
|
||||
// tuple_get
|
||||
//
|
||||
template<std::size_t I, typename T1, typename T2>
|
||||
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, std::pair<T1, T2> >::type&
|
||||
tuple_get(std::pair<T1, T2>& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < 2, "tuple_get: index out of range");
|
||||
return sprout::tuples::detail::get_impl<I, std::pair<T1, T2> >()(t);
|
||||
}
|
||||
template<std::size_t I, typename T1, typename T2>
|
||||
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, std::pair<T1, T2> >::type const&
|
||||
tuple_get(std::pair<T1, T2> const& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < 2, "tuple_get: index out of range");
|
||||
return sprout::tuples::detail::get_impl<I, std::pair<T1, T2> >()(t);
|
||||
}
|
||||
template<std::size_t I, typename T1, typename T2>
|
||||
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, std::pair<T1, T2> >::type&&
|
||||
tuple_get(std::pair<T1, T2>&& t) SPROUT_NOEXCEPT {
|
||||
return sprout::move(sprout::tuples::get<I>(t));
|
||||
}
|
||||
} // namespace sprout_adl
|
||||
namespace sprout {
|
||||
namespace tuples {
|
||||
//
|
||||
// tuple_access_traits
|
||||
//
|
||||
template<typename T1, typename T2>
|
||||
struct tuple_access_traits<std::pair<T1, T2> > {
|
||||
public:
|
||||
template<std::size_t I>
|
||||
static SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, std::pair<T1, T2> >::type&
|
||||
tuple_get(std::pair<T1, T2>& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < 2, "tuple_get: index out of range");
|
||||
return sprout::tuples::detail::get_impl<I, std::pair<T1, T2> >()(t);
|
||||
}
|
||||
template<std::size_t I>
|
||||
static SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, std::pair<T1, T2> >::type const&
|
||||
tuple_get(std::pair<T1, T2> const& t) SPROUT_NOEXCEPT {
|
||||
static_assert(I < 2, "tuple_get: index out of range");
|
||||
return sprout::tuples::detail::get_impl<I, std::pair<T1, T2> >()(t);
|
||||
}
|
||||
template<std::size_t I>
|
||||
static SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, std::pair<T1, T2> >::type&&
|
||||
tuple_get(std::pair<T1, T2>&& t) SPROUT_NOEXCEPT {
|
||||
return sprout::move(tuple_get<I>(t));
|
||||
}
|
||||
};
|
||||
} // namespace tuples
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_STD_UTILITY_HPP
|
||||
|
|
|
@ -6,11 +6,14 @@
|
|||
#include <sprout/tuple/tuple/tuple_decl.hpp>
|
||||
#include <sprout/tuple/tuple/tuple.hpp>
|
||||
#include <sprout/tuple/tuple/comparison.hpp>
|
||||
#include <sprout/tuple/tuple/tuple_size.hpp>
|
||||
#include <sprout/tuple/tuple/tuple_element.hpp>
|
||||
#include <sprout/tuple/tuple/get.hpp>
|
||||
#include <sprout/tuple/tuple/hash.hpp>
|
||||
#include <sprout/tuple/tuple/ignore.hpp>
|
||||
#include <sprout/tuple/tuple/make_tuple.hpp>
|
||||
#include <sprout/tuple/tuple/type_traits.hpp>
|
||||
#include <sprout/tuple/tuple/tuple_access_traits.hpp>
|
||||
#include <sprout/tuple/flexibly_construct.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_TUPLE_HPP
|
||||
|
|
|
@ -2,62 +2,21 @@
|
|||
#define SPROUT_TUPLE_TUPLE_GET_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
#include <tuple>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/enabler_if.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/tuple/tuple/tuple.hpp>
|
||||
#include <sprout/tuple/tuple/tuple_size.hpp>
|
||||
#include <sprout/tuple/tuple/tuple_element.hpp>
|
||||
#include <sprout/tuple/tuple/tuple_access_traits.hpp>
|
||||
#include <sprout/adl/not_found.hpp>
|
||||
|
||||
//#include <tuple>
|
||||
//#include <sprout/type_traits/enabler_if.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace tuples {
|
||||
//
|
||||
// tuple_size
|
||||
//
|
||||
template<typename T>
|
||||
struct tuple_size
|
||||
: public std::tuple_size<T>
|
||||
{};
|
||||
template<typename T>
|
||||
struct tuple_size<T const>
|
||||
: public sprout::tuples::tuple_size<T>
|
||||
{};
|
||||
template<typename T>
|
||||
struct tuple_size<T volatile>
|
||||
: public sprout::tuples::tuple_size<T>
|
||||
{};
|
||||
template<typename T>
|
||||
struct tuple_size<T const volatile>
|
||||
: public sprout::tuples::tuple_size<T>
|
||||
{};
|
||||
|
||||
//
|
||||
// tuple_element
|
||||
//
|
||||
template<std::size_t I, typename T>
|
||||
struct tuple_element
|
||||
: public std::tuple_element<I, T>
|
||||
{};
|
||||
template<std::size_t I, typename T>
|
||||
struct tuple_element<I, T const>
|
||||
: public std::add_const<
|
||||
typename sprout::tuples::tuple_element<I, T>::type
|
||||
>
|
||||
{};
|
||||
template<std::size_t I, typename T>
|
||||
struct tuple_element<I, T volatile>
|
||||
: public std::add_volatile<
|
||||
typename sprout::tuples::tuple_element<I, T>::type
|
||||
>
|
||||
{};
|
||||
template<std::size_t I, typename T>
|
||||
struct tuple_element<I, T const volatile>
|
||||
: public std::add_cv<
|
||||
typename sprout::tuples::tuple_element<I, T>::type
|
||||
>
|
||||
{};
|
||||
|
||||
namespace detail {
|
||||
template<std::size_t I, typename Head, typename... Tail>
|
||||
inline SPROUT_CONSTEXPR typename std::add_lvalue_reference<Head>::type
|
||||
|
@ -71,30 +30,28 @@ namespace sprout {
|
|||
}
|
||||
} // namespace detail
|
||||
//
|
||||
// get
|
||||
// tuple_get
|
||||
//
|
||||
template<std::size_t I, typename... Types>
|
||||
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sprout::tuples::tuple<Types...> >::type&
|
||||
get(sprout::tuples::tuple<Types...>& t) SPROUT_NOEXCEPT {
|
||||
tuple_get(sprout::tuples::tuple<Types...>& t) SPROUT_NOEXCEPT {
|
||||
return sprout::tuples::detail::get_helper<I>(t);
|
||||
}
|
||||
template<std::size_t I, typename... Types>
|
||||
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sprout::tuples::tuple<Types...> >::type&&
|
||||
get(sprout::tuples::tuple<Types...>&& t) SPROUT_NOEXCEPT {
|
||||
tuple_get(sprout::tuples::tuple<Types...>&& t) SPROUT_NOEXCEPT {
|
||||
return sprout::forward<typename sprout::tuples::tuple_element<I, sprout::tuples::tuple<Types...> >::type&&>(
|
||||
sprout::tuples::get<I>(t)
|
||||
sprout::tuples::tuple_get<I>(t)
|
||||
);
|
||||
}
|
||||
template<std::size_t I, typename... Types>
|
||||
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, sprout::tuples::tuple<Types...> >::type const&
|
||||
get(sprout::tuples::tuple<Types...> const& t) SPROUT_NOEXCEPT {
|
||||
tuple_get(sprout::tuples::tuple<Types...> const& t) SPROUT_NOEXCEPT {
|
||||
return sprout::tuples::detail::get_helper<I>(t);
|
||||
}
|
||||
} // namespace tuples
|
||||
|
||||
using sprout::tuples::tuple_size;
|
||||
using sprout::tuples::tuple_element;
|
||||
using sprout::tuples::get;
|
||||
using sprout::tuples::tuple_get;
|
||||
} // namespace sprout
|
||||
|
||||
namespace sprout_adl {
|
||||
|
@ -106,135 +63,37 @@ namespace sprout_tuple_detail {
|
|||
using sprout_adl::tuple_get;
|
||||
|
||||
template<std::size_t I, typename T>
|
||||
struct has_adl_tuple_get_test {
|
||||
public:
|
||||
template<
|
||||
typename U = T,
|
||||
typename sprout::enabler_if<
|
||||
sprout::is_found_via_adl<decltype(tuple_get<I>(std::declval<U>()))>::value
|
||||
>::type = sprout::enabler
|
||||
>
|
||||
static std::true_type test(int);
|
||||
static std::false_type test(...);
|
||||
};
|
||||
#if defined(_MSC_VER)
|
||||
template<std::size_t I, typename T, typename Base_ = decltype(sprout_tuple_detail::has_adl_tuple_get_test<I, T>::test(0))>
|
||||
struct has_adl_tuple_get
|
||||
: public Base_
|
||||
{};
|
||||
#else
|
||||
template<std::size_t I, typename T>
|
||||
struct has_adl_tuple_get
|
||||
: public decltype(sprout_tuple_detail::has_adl_tuple_get_test<I, T>::test(0))
|
||||
{};
|
||||
#endif
|
||||
|
||||
template<std::size_t I, typename T>
|
||||
struct has_std_get_test {
|
||||
public:
|
||||
template<
|
||||
typename U = T,
|
||||
typename = decltype(std::get<I>(std::declval<U>()))
|
||||
>
|
||||
static std::true_type test(int);
|
||||
static std::false_type test(...);
|
||||
};
|
||||
#if defined(_MSC_VER)
|
||||
template<std::size_t I, typename T, typename Base_ = decltype(sprout_tuple_detail::has_std_get_test<I, T>::test(0))>
|
||||
struct has_std_get
|
||||
: public Base_
|
||||
{};
|
||||
#else
|
||||
template<std::size_t I, typename T>
|
||||
struct has_std_get
|
||||
: public decltype(sprout_tuple_detail::has_std_get_test<I, T>::test(0))
|
||||
{};
|
||||
#endif
|
||||
|
||||
template<std::size_t I, typename T, typename Enable = void>
|
||||
struct select_adl_tuple_get;
|
||||
template<std::size_t I, typename T>
|
||||
struct select_adl_tuple_get<
|
||||
I, T,
|
||||
typename std::enable_if<sprout_tuple_detail::has_adl_tuple_get<I, T>::value>::type
|
||||
>
|
||||
: public std::true_type
|
||||
{};
|
||||
template<std::size_t I, typename T>
|
||||
struct select_adl_tuple_get<
|
||||
I, T,
|
||||
typename std::enable_if<!sprout_tuple_detail::has_adl_tuple_get<I, T>::value>::type
|
||||
>
|
||||
: public std::false_type
|
||||
{};
|
||||
|
||||
template<std::size_t I, typename T, typename Enable = void>
|
||||
struct select_std_get;
|
||||
template<std::size_t I, typename T>
|
||||
struct select_std_get<
|
||||
I, T,
|
||||
typename std::enable_if<
|
||||
sprout_tuple_detail::has_std_get<I, T>::value
|
||||
&& !sprout_tuple_detail::has_adl_tuple_get<I, T>::value
|
||||
>::type
|
||||
>
|
||||
: public std::true_type
|
||||
{};
|
||||
template<std::size_t I, typename T>
|
||||
struct select_std_get<
|
||||
I, T,
|
||||
typename std::enable_if<!(
|
||||
sprout_tuple_detail::has_std_get<I, T>::value
|
||||
&& !sprout_tuple_detail::has_adl_tuple_get<I, T>::value
|
||||
)>::type
|
||||
>
|
||||
: public std::false_type
|
||||
{};
|
||||
|
||||
template<std::size_t I, typename T, typename = void>
|
||||
struct noexcept_get;
|
||||
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, T>::type&
|
||||
tuple_get(T& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::tuple_access_traits<T>::template tuple_get<I>(std::declval<T>())))
|
||||
{
|
||||
return sprout::tuples::tuple_access_traits<T>::template tuple_get<I>(t);
|
||||
}
|
||||
template<std::size_t I, typename T>
|
||||
struct noexcept_get<I, T, typename std::enable_if<sprout_tuple_detail::select_adl_tuple_get<I, T>::value>::type>
|
||||
: public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(tuple_get<I>(std::declval<T>()), false)>
|
||||
{};
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!std::is_const<T>::value && !std::is_volatile<T>::value && !std::is_reference<T>::value,
|
||||
typename sprout::tuples::tuple_element<I, typename std::remove_reference<T>::type>::type&&
|
||||
>::type
|
||||
tuple_get(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::tuple_access_traits<typename std::remove_reference<T>::type>::template tuple_get<I>(std::declval<T>())))
|
||||
{
|
||||
return sprout::tuples::tuple_access_traits<T>::template tuple_get<I>(t);
|
||||
}
|
||||
template<std::size_t I, typename T>
|
||||
struct noexcept_get<I, T, typename std::enable_if<sprout_tuple_detail::select_std_get<I, T>::value>::type>
|
||||
: public std::integral_constant<bool, SPROUT_NOEXCEPT_EXPR_OR_DEFAULT(std::get<I>(std::declval<T>()), false)>
|
||||
{};
|
||||
inline SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, T>::type const&
|
||||
tuple_get(T const& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::tuples::tuple_access_traits<T const>::template tuple_get<I>(std::declval<T>())))
|
||||
{
|
||||
return sprout::tuples::tuple_access_traits<T const>::template tuple_get<I>(t);
|
||||
}
|
||||
|
||||
template<std::size_t I, typename T, typename = void>
|
||||
struct get_result;
|
||||
template<std::size_t I, typename T>
|
||||
struct get_result<I, T, typename std::enable_if<sprout_tuple_detail::select_adl_tuple_get<I, T>::value>::type> {
|
||||
public:
|
||||
typedef decltype(tuple_get<I>(std::declval<T>())) type;
|
||||
};
|
||||
template<std::size_t I, typename T>
|
||||
struct get_result<I, T, typename std::enable_if<sprout_tuple_detail::select_std_get<I, T>::value>::type> {
|
||||
public:
|
||||
typedef decltype(std::get<I>(std::declval<T>())) type;
|
||||
};
|
||||
|
||||
template<
|
||||
std::size_t I, typename T,
|
||||
typename sprout::enabler_if<sprout_tuple_detail::select_adl_tuple_get<I, T>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR typename sprout_tuple_detail::get_result<I, T>::type
|
||||
get_impl(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR((sprout_tuple_detail::noexcept_get<I, T>::value))
|
||||
inline SPROUT_CONSTEXPR decltype(tuple_get<I>(std::declval<T>()))
|
||||
call_tuple_get(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(tuple_get<I>(std::declval<T>())))
|
||||
{
|
||||
return tuple_get<I>(sprout::forward<T>(t));
|
||||
}
|
||||
template<
|
||||
std::size_t I, typename T,
|
||||
typename sprout::enabler_if<sprout_tuple_detail::select_std_get<I, T>::value>::type = sprout::enabler
|
||||
>
|
||||
inline SPROUT_CONSTEXPR typename sprout_tuple_detail::get_result<I, T>::type
|
||||
get_impl(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR((sprout_tuple_detail::noexcept_get<I, T>::value))
|
||||
{
|
||||
return std::get<I>(sprout::forward<T>(t));
|
||||
}
|
||||
} // namespace sprout_tuple_detail
|
||||
|
||||
namespace sprout {
|
||||
|
@ -243,11 +102,11 @@ namespace sprout {
|
|||
// get
|
||||
//
|
||||
template<std::size_t I, typename T>
|
||||
inline SPROUT_CONSTEXPR typename sprout_tuple_detail::get_result<I, T>::type
|
||||
inline SPROUT_CONSTEXPR decltype(sprout_tuple_detail::call_tuple_get<I>(std::declval<T>()))
|
||||
get(T&& t)
|
||||
SPROUT_NOEXCEPT_EXPR((sprout_tuple_detail::noexcept_get<I, T>::value))
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout_tuple_detail::call_tuple_get<I>(std::declval<T>())))
|
||||
{
|
||||
return sprout_tuple_detail::get_impl<I>(sprout::forward<T>(t));
|
||||
return sprout_tuple_detail::call_tuple_get<I>(sprout::forward<T>(t));
|
||||
}
|
||||
} // namespace tuples
|
||||
|
||||
|
|
47
sprout/tuple/tuple/tuple_access_traits.hpp
Normal file
47
sprout/tuple/tuple/tuple_access_traits.hpp
Normal file
|
@ -0,0 +1,47 @@
|
|||
#ifndef SPROUT_TUPLE_TUPLE_TUPLE_ACCESS_TRAITS_HPP
|
||||
#define SPROUT_TUPLE_TUPLE_TUPLE_ACCESS_TRAITS_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <tuple>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/tuple/tuple/tuple_element.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace tuples {
|
||||
//
|
||||
// tuple_access_traits
|
||||
//
|
||||
template<typename Tuple>
|
||||
struct tuple_access_traits {
|
||||
public:
|
||||
template<std::size_t I>
|
||||
static SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, Tuple>::type&
|
||||
tuple_get(Tuple& t) SPROUT_NOEXCEPT {
|
||||
return std::get<I>(t);
|
||||
}
|
||||
template<std::size_t I>
|
||||
static SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, Tuple>::type&&
|
||||
tuple_get(Tuple&& t) SPROUT_NOEXCEPT {
|
||||
return std::get<I>(t);
|
||||
}
|
||||
template<std::size_t I>
|
||||
static SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, Tuple>::type const&
|
||||
tuple_get(Tuple const& t) SPROUT_NOEXCEPT {
|
||||
return std::get<I>(t);
|
||||
}
|
||||
};
|
||||
template<typename Tuple>
|
||||
struct tuple_access_traits<Tuple const> {
|
||||
public:
|
||||
template<std::size_t I>
|
||||
static SPROUT_CONSTEXPR typename sprout::tuples::tuple_element<I, Tuple>::type const&
|
||||
tuple_get(Tuple const& t) SPROUT_NOEXCEPT {
|
||||
return sprout::tuples::tuple_access_traits<Tuple>::template tuple_get<I>(t);
|
||||
}
|
||||
};
|
||||
} // namespace tuples
|
||||
|
||||
using sprout::tuples::tuple_access_traits;
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_TUPLE_TUPLE_ACCESS_TRAITS_HPP
|
41
sprout/tuple/tuple/tuple_element.hpp
Normal file
41
sprout/tuple/tuple/tuple_element.hpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
#ifndef SPROUT_TUPLE_TUPLE_TUPLE_ELEMENT_HPP
|
||||
#define SPROUT_TUPLE_TUPLE_TUPLE_ELEMENT_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <tuple>
|
||||
#include <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace tuples {
|
||||
//
|
||||
// tuple_element
|
||||
//
|
||||
template<std::size_t I, typename T>
|
||||
struct tuple_element
|
||||
: public std::tuple_element<I, T>
|
||||
{};
|
||||
template<std::size_t I, typename T>
|
||||
struct tuple_element<I, T const>
|
||||
: public std::add_const<
|
||||
typename sprout::tuples::tuple_element<I, T>::type
|
||||
>
|
||||
{};
|
||||
template<std::size_t I, typename T>
|
||||
struct tuple_element<I, T volatile>
|
||||
: public std::add_volatile<
|
||||
typename sprout::tuples::tuple_element<I, T>::type
|
||||
>
|
||||
{};
|
||||
template<std::size_t I, typename T>
|
||||
struct tuple_element<I, T const volatile>
|
||||
: public std::add_cv<
|
||||
typename sprout::tuples::tuple_element<I, T>::type
|
||||
>
|
||||
{};
|
||||
} // namespace tuples
|
||||
|
||||
using sprout::tuples::tuple_element;
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_TUPLE_TUPLE_ELEMENT_HPP
|
33
sprout/tuple/tuple/tuple_size.hpp
Normal file
33
sprout/tuple/tuple/tuple_size.hpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
#ifndef SPROUT_TUPLE_TUPLE_TUPLE_SIZE_HPP
|
||||
#define SPROUT_TUPLE_TUPLE_TUPLE_SIZE_HPP
|
||||
|
||||
#include <tuple>
|
||||
#include <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace tuples {
|
||||
//
|
||||
// tuple_size
|
||||
//
|
||||
template<typename T>
|
||||
struct tuple_size
|
||||
: public std::tuple_size<T>
|
||||
{};
|
||||
template<typename T>
|
||||
struct tuple_size<T const>
|
||||
: public sprout::tuples::tuple_size<T>
|
||||
{};
|
||||
template<typename T>
|
||||
struct tuple_size<T volatile>
|
||||
: public sprout::tuples::tuple_size<T>
|
||||
{};
|
||||
template<typename T>
|
||||
struct tuple_size<T const volatile>
|
||||
: public sprout::tuples::tuple_size<T>
|
||||
{};
|
||||
} // namespace tuples
|
||||
|
||||
using sprout::tuples::tuple_size;
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TUPLE_TUPLE_TUPLE_SIZE_HPP
|
Loading…
Reference in a new issue