mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2024-11-12 21:09:01 +00:00
add iterator_traits: SFINAE-friendly version
This commit is contained in:
parent
c15de6136b
commit
f45298f81f
3 changed files with 53 additions and 2 deletions
|
@ -9,6 +9,7 @@
|
|||
#define SPROUT_ITERATOR_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/iterator_traits.hpp>
|
||||
#include <sprout/iterator/type_traits.hpp>
|
||||
#include <sprout/iterator/operation.hpp>
|
||||
#include <sprout/iterator/predefined.hpp>
|
||||
|
|
50
sprout/iterator/iterator_traits.hpp
Normal file
50
sprout/iterator/iterator_traits.hpp
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2014 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_ITERATOR_ITERATOR_TRAITS_HPP
|
||||
#define SPROUT_ITERATOR_ITERATOR_TRAITS_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/utility/pack.hpp>
|
||||
#include <sprout/detail/nil_base.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// iterator_traits
|
||||
//
|
||||
namespace detail {
|
||||
template<typename Iterator, typename = void>
|
||||
struct iterator_traits_impl
|
||||
: public sprout::detail::nil_base
|
||||
{};
|
||||
template<typename Iterator>
|
||||
struct iterator_traits_impl<
|
||||
Iterator,
|
||||
typename sprout::head_element<
|
||||
void,
|
||||
typename Iterator::difference_type,
|
||||
typename Iterator::value_type,
|
||||
typename Iterator::pointer,
|
||||
typename Iterator::reference,
|
||||
typename Iterator::iterator_category
|
||||
>::type
|
||||
>
|
||||
: public std::iterator_traits<Iterator>
|
||||
{};
|
||||
} // namespace detail
|
||||
template<typename Iterator>
|
||||
struct iterator_traits
|
||||
: public sprout::detail::iterator_traits_impl<Iterator>
|
||||
{};
|
||||
template<typename T>
|
||||
struct iterator_traits<T*>
|
||||
: public std::iterator_traits<T*>
|
||||
{};
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_ITERATOR_ITERATOR_TRAITS_HPP
|
|
@ -8,9 +8,9 @@
|
|||
#ifndef SPROUT_ITERATOR_TYPE_TRAITS_IS_ITERATOR_HPP
|
||||
#define SPROUT_ITERATOR_TYPE_TRAITS_IS_ITERATOR_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/type_traits/has_xxx.hpp>
|
||||
#include <sprout/iterator/iterator_traits.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace detail {
|
||||
|
@ -25,7 +25,7 @@ namespace sprout {
|
|||
//
|
||||
template<typename T>
|
||||
struct is_iterator
|
||||
: public sprout::detail::has_iterator_category<std::iterator_traits<T> >
|
||||
: public sprout::detail::has_iterator_category<sprout::iterator_traits<T> >
|
||||
{};
|
||||
|
||||
#if SPROUT_USE_VARIABLE_TEMPLATES
|
||||
|
|
Loading…
Reference in a new issue