mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
change begin, end traits
This commit is contained in:
parent
e5637554d1
commit
a6d46d4ffa
9 changed files with 445 additions and 5 deletions
|
@ -23,7 +23,9 @@ namespace sprout {
|
|||
// ADL callable range_begin(cont) -> range_begin(cont)
|
||||
// [default]
|
||||
// Container is T[N] -> iterator(cont)
|
||||
// otherwise -> cont.begin()
|
||||
// otherwise, ADL callable begin(cont) -> begin(cont)
|
||||
// otherwise, callabe cont.begin() -> cont.begin()
|
||||
// otherwise -> std::begin(cont)
|
||||
//
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
|
|
|
@ -8,12 +8,14 @@
|
|||
#ifndef SPROUT_CONTAINER_CONTAINER_RANGE_TRAITS_HPP
|
||||
#define SPROUT_CONTAINER_CONTAINER_RANGE_TRAITS_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
#include <sprout/workaround/std/cstddef.hpp>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/integral_constant.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/type_traits/is_within_namespace_sprout.hpp>
|
||||
#include <sprout/container/traits_fwd.hpp>
|
||||
#include <sprout/container/container_traits.hpp>
|
||||
#include <sprout/container/range_functions_fwd.hpp>
|
||||
|
@ -21,6 +23,9 @@
|
|||
#include <sprout/adl/not_found.hpp>
|
||||
|
||||
namespace sprout_adl {
|
||||
sprout::not_found_via_adl begin(...);
|
||||
sprout::not_found_via_adl end(...);
|
||||
|
||||
sprout::not_found_via_adl range_begin(...);
|
||||
sprout::not_found_via_adl range_end(...);
|
||||
sprout::not_found_via_adl range_size(...);
|
||||
|
@ -33,8 +38,266 @@ namespace sprout_adl {
|
|||
sprout::not_found_via_adl range_data(...);
|
||||
} // namespace sprout_adl
|
||||
|
||||
|
||||
namespace sprout_container_range_detail {
|
||||
using sprout_adl::begin;
|
||||
using sprout_adl::end;
|
||||
|
||||
template<typename T>
|
||||
struct has_adl_begin_test {
|
||||
public:
|
||||
template<
|
||||
typename U = T,
|
||||
typename R = typename sprout::identity<decltype(begin(std::declval<U>()))>::type
|
||||
>
|
||||
static sprout::is_found_via_adl<R> test(int);
|
||||
static sprout::false_type test(...);
|
||||
};
|
||||
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
range_adl_begin(Container& cont) {
|
||||
return begin(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
range_adl_begin(Container const& cont) {
|
||||
return begin(cont);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct has_adl_end_test {
|
||||
public:
|
||||
template<
|
||||
typename U = T,
|
||||
typename R = typename sprout::identity<decltype(end(std::declval<U>()))>::type
|
||||
>
|
||||
static sprout::is_found_via_adl<R> test(int);
|
||||
static sprout::false_type test(...);
|
||||
};
|
||||
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
range_adl_end(Container& cont) {
|
||||
return end(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
range_adl_end(Container const& cont) {
|
||||
return end(cont);
|
||||
}
|
||||
} // namespace sprout_container_range_detail
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
#if defined(_MSC_VER) && (_MSC_VER > 1900)
|
||||
template<typename T, typename Base_ = typename sprout::identity<decltype(sprout_container_range_detail::has_adl_begin_test<T>::test(0))>::type>
|
||||
struct has_adl_begin
|
||||
: public Base_
|
||||
{};
|
||||
#else
|
||||
template<typename T>
|
||||
struct has_adl_begin
|
||||
: public sprout::identity<decltype(sprout_container_range_detail::has_adl_begin_test<T>::test(0))>::type
|
||||
{};
|
||||
#endif
|
||||
template<typename T, bool = sprout::is_within_namespace_sprout<T>::value>
|
||||
struct has_adl_begin_without_sprout
|
||||
: public sprout::false_type
|
||||
{};
|
||||
template<typename T>
|
||||
struct has_adl_begin_without_sprout<T, false>
|
||||
: public sprout::detail::has_adl_begin<T>
|
||||
{};
|
||||
|
||||
template<typename T>
|
||||
struct has_mem_begin_test {
|
||||
public:
|
||||
template<
|
||||
typename U = T,
|
||||
typename = typename sprout::identity<decltype(std::declval<U>().begin())>::type
|
||||
>
|
||||
static sprout::true_type test(int);
|
||||
static sprout::false_type test(...);
|
||||
};
|
||||
#if defined(_MSC_VER) && (_MSC_VER > 1900)
|
||||
template<typename T, typename Base_ = typename sprout::identity<decltype(sprout::detail::has_mem_begin_test<T>::test(0))>::type>
|
||||
struct has_mem_begin
|
||||
: public Base_
|
||||
{};
|
||||
#else
|
||||
template<typename T>
|
||||
struct has_mem_begin
|
||||
: public sprout::identity<decltype(sprout::detail::has_mem_begin_test<T>::test(0))>::type
|
||||
{};
|
||||
#endif
|
||||
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
range_adl_begin(Container& cont) {
|
||||
using std::begin;
|
||||
return begin(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
range_adl_begin(Container const& cont) {
|
||||
using std::begin;
|
||||
return begin(cont);
|
||||
}
|
||||
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::detail::has_adl_begin_without_sprout<Container&>::value,
|
||||
typename sprout::container_traits<Container>::iterator
|
||||
>::type
|
||||
range_begin_impl(Container& cont) {
|
||||
return sprout_container_range_detail::range_adl_begin(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!sprout::detail::has_adl_begin_without_sprout<Container&>::value && sprout::detail::has_mem_begin<Container>::value,
|
||||
typename sprout::container_traits<Container>::iterator
|
||||
>::type
|
||||
range_begin_impl(Container& cont) {
|
||||
return cont.begin();
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!sprout::detail::has_adl_begin_without_sprout<Container&>::value && !sprout::detail::has_mem_begin<Container>::value,
|
||||
typename sprout::container_traits<Container>::iterator
|
||||
>::type
|
||||
range_begin_impl(Container& cont) {
|
||||
return std::begin(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::detail::has_adl_begin_without_sprout<Container const&>::value,
|
||||
typename sprout::container_traits<Container const>::iterator
|
||||
>::type
|
||||
range_begin_impl(Container const& cont) {
|
||||
return sprout_container_range_detail::range_adl_begin(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!sprout::detail::has_adl_begin_without_sprout<Container const&>::value && sprout::detail::has_mem_begin<Container const>::value,
|
||||
typename sprout::container_traits<Container const>::iterator
|
||||
>::type
|
||||
range_begin_impl(Container const& cont) {
|
||||
return cont.begin();
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!sprout::detail::has_adl_begin_without_sprout<Container const&>::value && !sprout::detail::has_mem_begin<Container const>::value,
|
||||
typename sprout::container_traits<Container const>::iterator
|
||||
>::type
|
||||
range_begin_impl(Container const& cont) {
|
||||
return std::begin(cont);
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER > 1900)
|
||||
template<typename T, typename Base_ = typename sprout::identity<decltype(sprout_container_range_detail::has_adl_end_test<T>::test(0))>::type>
|
||||
struct has_adl_end
|
||||
: public Base_
|
||||
{};
|
||||
#else
|
||||
template<typename T>
|
||||
struct has_adl_end
|
||||
: public sprout::identity<decltype(sprout_container_range_detail::has_adl_end_test<T>::test(0))>::type
|
||||
{};
|
||||
#endif
|
||||
template<typename T, bool = sprout::is_within_namespace_sprout<T>::value>
|
||||
struct has_adl_end_without_sprout
|
||||
: public sprout::false_type
|
||||
{};
|
||||
template<typename T>
|
||||
struct has_adl_end_without_sprout<T, false>
|
||||
: public sprout::detail::has_adl_end<T>
|
||||
{};
|
||||
|
||||
template<typename T>
|
||||
struct has_mem_end_test {
|
||||
public:
|
||||
template<
|
||||
typename U = T,
|
||||
typename = typename sprout::identity<decltype(std::declval<U>().end())>::type
|
||||
>
|
||||
static sprout::true_type test(int);
|
||||
static sprout::false_type test(...);
|
||||
};
|
||||
#if defined(_MSC_VER) && (_MSC_VER > 1900)
|
||||
template<typename T, typename Base_ = typename sprout::identity<decltype(sprout::detail::has_mem_end_test<T>::test(0))>::type>
|
||||
struct has_mem_end
|
||||
: public Base_
|
||||
{};
|
||||
#else
|
||||
template<typename T>
|
||||
struct has_mem_end
|
||||
: public sprout::identity<decltype(sprout::detail::has_mem_end_test<T>::test(0))>::type
|
||||
{};
|
||||
#endif
|
||||
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
range_adl_end(Container& cont) {
|
||||
using std::end;
|
||||
return end(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
range_adl_end(Container const& cont) {
|
||||
using std::end;
|
||||
return end(cont);
|
||||
}
|
||||
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::detail::has_adl_end_without_sprout<Container&>::value,
|
||||
typename sprout::container_traits<Container>::iterator
|
||||
>::type
|
||||
range_end_impl(Container& cont) {
|
||||
return sprout_container_range_detail::range_adl_end(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!sprout::detail::has_adl_end_without_sprout<Container&>::value && sprout::detail::has_mem_end<Container>::value,
|
||||
typename sprout::container_traits<Container>::iterator
|
||||
>::type
|
||||
range_end_impl(Container& cont) {
|
||||
return cont.end();
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!sprout::detail::has_adl_end_without_sprout<Container&>::value && !sprout::detail::has_mem_end<Container>::value,
|
||||
typename sprout::container_traits<Container>::iterator
|
||||
>::type
|
||||
range_end_impl(Container& cont) {
|
||||
return std::end(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
sprout::detail::has_adl_end_without_sprout<Container const&>::value,
|
||||
typename sprout::container_traits<Container const>::iterator
|
||||
>::type
|
||||
range_end_impl(Container const& cont) {
|
||||
return sprout_container_range_detail::range_adl_end(cont);
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!sprout::detail::has_adl_end_without_sprout<Container const&>::value && sprout::detail::has_mem_end<Container const>::value,
|
||||
typename sprout::container_traits<Container const>::iterator
|
||||
>::type
|
||||
range_end_impl(Container const& cont) {
|
||||
return cont.end();
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename std::enable_if<
|
||||
!sprout::detail::has_adl_end_without_sprout<Container const&>::value && !sprout::detail::has_mem_end<Container const>::value,
|
||||
typename sprout::container_traits<Container const>::iterator
|
||||
>::type
|
||||
range_end_impl(Container const& cont) {
|
||||
return std::end(cont);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct has_mem_size_test {
|
||||
public:
|
||||
|
@ -394,12 +657,14 @@ namespace sprout_container_range_detail {
|
|||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
range_begin(Container& cont) {
|
||||
return cont.begin();
|
||||
return sprout::detail::range_begin_impl(cont);
|
||||
// return cont.begin();
|
||||
}
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container const>::iterator
|
||||
range_begin(Container const& cont) {
|
||||
return cont.begin();
|
||||
return sprout::detail::range_begin_impl(cont);
|
||||
// return cont.begin();
|
||||
}
|
||||
|
||||
template<typename Container>
|
||||
|
|
|
@ -22,8 +22,10 @@ namespace sprout {
|
|||
// [default]
|
||||
// ADL callable range_end(cont) -> range_end(cont)
|
||||
// [default]
|
||||
// Container is T[N] -> iterator(cont) + N
|
||||
// otherwise -> cont.end()
|
||||
// Container is T[N] -> iterator(cont)
|
||||
// otherwise, ADL callable end(cont) -> end(cont)
|
||||
// otherwise, callabe cont.end() -> cont.end()
|
||||
// otherwise -> std::end(cont)
|
||||
//
|
||||
template<typename Container>
|
||||
inline SPROUT_CONSTEXPR typename sprout::container_traits<Container>::iterator
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <sprout/type_traits/std.hpp>
|
||||
#include <sprout/type_traits/composite_modification.hpp>
|
||||
#include <sprout/type_traits/has_operator.hpp>
|
||||
#include <sprout/type_traits/is_within_namespace.hpp>
|
||||
#include <sprout/type_traits/introspection.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_HPP
|
||||
|
|
15
sprout/type_traits/is_within_namespace.hpp
Normal file
15
sprout/type_traits/is_within_namespace.hpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2016 Bolero MURAKAMI
|
||||
https://github.com/bolero-MURAKAMI/Sprout
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_HPP
|
||||
#define SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/is_within_namespace_sprout.hpp>
|
||||
#include <sprout/type_traits/is_within_namespace_boost.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_HPP
|
60
sprout/type_traits/is_within_namespace_boost.hpp
Normal file
60
sprout/type_traits/is_within_namespace_boost.hpp
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2016 Bolero MURAKAMI
|
||||
https://github.com/bolero-MURAKAMI/Sprout
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_BOOST_HPP
|
||||
#define SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_BOOST_HPP
|
||||
|
||||
#include <utility>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/integral_constant.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/adl/not_found.hpp>
|
||||
|
||||
namespace sprout_adl {
|
||||
sprout::not_found_via_adl sprout_adl_tester_namespace_boost(...);
|
||||
} // namespace sprout_adl
|
||||
|
||||
namespace boost {
|
||||
template<typename T>
|
||||
void sprout_adl_tester_namespace_boost(T&&);
|
||||
} // namespace boost
|
||||
|
||||
namespace sprout_adl_tester_detail {
|
||||
using sprout_adl::sprout_adl_tester_namespace_boost;
|
||||
|
||||
template<typename T>
|
||||
struct is_within_namespace_boost_test {
|
||||
public:
|
||||
template<
|
||||
typename U = T,
|
||||
typename R = typename sprout::identity<decltype(sprout_adl_tester_namespace_boost(std::declval<U>()))>::type
|
||||
>
|
||||
static sprout::is_found_via_adl<R> test(int);
|
||||
static sprout::false_type test(...);
|
||||
};
|
||||
} // namespace sprout_adl_tester_detail
|
||||
|
||||
namespace sprout {
|
||||
#if defined(_MSC_VER) && (_MSC_VER > 1900)
|
||||
template<typename T, typename Base_ = typename sprout::identity<decltype(sprout_adl_tester_detail::is_within_namespace_boost_test<T>::test(0))>::type>
|
||||
struct is_within_namespace_boost
|
||||
: public Base_
|
||||
{};
|
||||
#else
|
||||
template<typename T>
|
||||
struct is_within_namespace_boost
|
||||
: public sprout::identity<decltype(sprout_adl_tester_detail::is_within_namespace_boost_test<T>::test(0))>::type
|
||||
{};
|
||||
#endif
|
||||
|
||||
#if SPROUT_USE_VARIABLE_TEMPLATES
|
||||
template<typename T>
|
||||
SPROUT_STATIC_CONSTEXPR bool is_within_namespace_boost_v = sprout::is_within_namespace_boost<T>::value;
|
||||
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_BOOST_HPP
|
60
sprout/type_traits/is_within_namespace_sprout.hpp
Normal file
60
sprout/type_traits/is_within_namespace_sprout.hpp
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2016 Bolero MURAKAMI
|
||||
https://github.com/bolero-MURAKAMI/Sprout
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_SPROUT_HPP
|
||||
#define SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_SPROUT_HPP
|
||||
|
||||
#include <utility>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/integral_constant.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
#include <sprout/adl/not_found.hpp>
|
||||
|
||||
namespace sprout_adl {
|
||||
sprout::not_found_via_adl sprout_adl_tester_namespace_sprout(...);
|
||||
} // namespace sprout_adl
|
||||
|
||||
namespace sprout {
|
||||
template<typename T>
|
||||
void sprout_adl_tester_namespace_sprout(T&&);
|
||||
} // namespace sprout
|
||||
|
||||
namespace sprout_adl_tester_detail {
|
||||
using sprout_adl::sprout_adl_tester_namespace_sprout;
|
||||
|
||||
template<typename T>
|
||||
struct is_within_namespace_sprout_test {
|
||||
public:
|
||||
template<
|
||||
typename U = T,
|
||||
typename R = typename sprout::identity<decltype(sprout_adl_tester_namespace_sprout(std::declval<U>()))>::type
|
||||
>
|
||||
static sprout::is_found_via_adl<R> test(int);
|
||||
static sprout::false_type test(...);
|
||||
};
|
||||
} // namespace sprout_adl_tester_detail
|
||||
|
||||
namespace sprout {
|
||||
#if defined(_MSC_VER) && (_MSC_VER > 1900)
|
||||
template<typename T, typename Base_ = typename sprout::identity<decltype(sprout_adl_tester_detail::is_within_namespace_sprout_test<T>::test(0))>::type>
|
||||
struct is_within_namespace_sprout
|
||||
: public Base_
|
||||
{};
|
||||
#else
|
||||
template<typename T>
|
||||
struct is_within_namespace_sprout
|
||||
: public sprout::identity<decltype(sprout_adl_tester_detail::is_within_namespace_sprout_test<T>::test(0))>::type
|
||||
{};
|
||||
#endif
|
||||
|
||||
#if SPROUT_USE_VARIABLE_TEMPLATES
|
||||
template<typename T>
|
||||
SPROUT_STATIC_CONSTEXPR bool is_within_namespace_sprout_v = sprout::is_within_namespace_sprout<T>::value;
|
||||
#endif // #if SPROUT_USE_VARIABLE_TEMPLATES
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_TYPE_TRAITS_IS_WITHIN_NAMESPACE_SPROUT_HPP
|
34
sprout/utility/as_non_const.hpp
Normal file
34
sprout/utility/as_non_const.hpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2016 Bolero MURAKAMI
|
||||
https://github.com/bolero-MURAKAMI/Sprout
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_UTILITY_AS_NON_CONST_HPP
|
||||
#define SPROUT_UTILITY_AS_NON_CONST_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// as_non_const
|
||||
//
|
||||
template<typename T>
|
||||
inline SPROUT_CONSTEXPR typename std::conditional<
|
||||
std::is_lvalue_reference<T>::value,
|
||||
typename std::remove_const<typename std::remove_reference<T>::type>::type&,
|
||||
typename std::remove_const<typename std::remove_reference<T>::type>::type&&
|
||||
>::type
|
||||
as_non_const(T&& t) {
|
||||
typedef typename std::conditional<
|
||||
std::is_lvalue_reference<T>::value,
|
||||
typename std::remove_const<typename std::remove_reference<T>::type>::type&,
|
||||
typename std::remove_const<typename std::remove_reference<T>::type>::type&&
|
||||
>::type type;
|
||||
return const_cast<type>(t);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_UTILITY_AS_NON_CONST_HPP
|
|
@ -11,6 +11,7 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/utility/as_lvalue.hpp>
|
||||
#include <sprout/utility/as_const.hpp>
|
||||
#include <sprout/utility/as_non_const.hpp>
|
||||
#include <sprout/utility/lvalue_forward.hpp>
|
||||
#include <sprout/utility/unmove.hpp>
|
||||
#include <sprout/utility/pass_through.hpp>
|
||||
|
|
Loading…
Reference in a new issue