fix counting_iterator

This commit is contained in:
bolero-MURAKAMI 2012-05-23 19:33:06 +09:00
parent ea22a6ba5c
commit a9da4b2a1f
11 changed files with 141 additions and 89 deletions

View file

@ -12,7 +12,7 @@
#include <sprout/range/adaptor/size_enumed.hpp> #include <sprout/range/adaptor/size_enumed.hpp>
#include <sprout/range/algorithm/lower_bound.hpp> #include <sprout/range/algorithm/lower_bound.hpp>
#include <sprout/range/numeric/partial_sum.hpp> #include <sprout/range/numeric/partial_sum.hpp>
#include <sprout/weed/traits/type/is_c_str.hpp> #include <sprout/type_traits/is_c_str.hpp>
namespace sprout { namespace sprout {
namespace algorithm { namespace algorithm {
@ -22,7 +22,7 @@ namespace sprout {
template<typename String> template<typename String>
struct string_size< struct string_size<
String, String,
typename std::enable_if<sprout::weed::traits::is_c_str<String>::value>::type typename std::enable_if<sprout::is_c_str<String>::value>::type
> >
: public std::integral_constant< : public std::integral_constant<
typename sprout::container_traits<String>::size_type, typename sprout::container_traits<String>::size_type,
@ -32,7 +32,7 @@ namespace sprout {
template<typename String> template<typename String>
struct string_size< struct string_size<
String, String,
typename std::enable_if<!sprout::weed::traits::is_c_str<String>::value>::type typename std::enable_if<!sprout::is_c_str<String>::value>::type
> >
: public std::integral_constant< : public std::integral_constant<
typename sprout::container_traits<String>::size_type, typename sprout::container_traits<String>::size_type,
@ -42,7 +42,7 @@ namespace sprout {
template< template<
typename String, typename String,
typename sprout::enabler_if<sprout::weed::traits::is_c_str<String>::value>::type = sprout::enabler typename sprout::enabler_if<sprout::is_c_str<String>::value>::type = sprout::enabler
> >
inline SPROUT_CONSTEXPR typename sprout::container_traits<String>::difference_type inline SPROUT_CONSTEXPR typename sprout::container_traits<String>::difference_type
str_size(String const& str) { str_size(String const& str) {
@ -50,7 +50,7 @@ namespace sprout {
} }
template< template<
typename String, typename String,
typename sprout::enabler_if<!sprout::weed::traits::is_c_str<String>::value>::type = sprout::enabler typename sprout::enabler_if<!sprout::is_c_str<String>::value>::type = sprout::enabler
> >
inline SPROUT_CONSTEXPR typename sprout::container_traits<String>::difference_type inline SPROUT_CONSTEXPR typename sprout::container_traits<String>::difference_type
str_size(String const& str) { str_size(String const& str) {

View file

@ -14,7 +14,7 @@
#include <sprout/utility/enabler_if.hpp> #include <sprout/utility/enabler_if.hpp>
#include <sprout/range/algorithm/lower_bound.hpp> #include <sprout/range/algorithm/lower_bound.hpp>
#include <sprout/range/numeric/partial_sum.hpp> #include <sprout/range/numeric/partial_sum.hpp>
#include <sprout/weed/traits/type/is_char_type.hpp> #include <sprout/type_traits/is_char_type.hpp>
#include <sprout/detail/param_at.hpp> #include <sprout/detail/param_at.hpp>
#include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT
@ -676,7 +676,7 @@ namespace sprout {
typename Elem, std::size_t N, typename T, typename Elem, std::size_t N, typename T,
typename sprout::enabler_if< typename sprout::enabler_if<
std::is_integral<T>::value std::is_integral<T>::value
&& !sprout::weed::traits::is_char_type<T>::value && !sprout::is_char_type<T>::value
>::type = sprout::enabler >::type = sprout::enabler
> >
inline SPROUT_CONSTEXPR auto inline SPROUT_CONSTEXPR auto
@ -697,7 +697,7 @@ namespace sprout {
} }
template< template<
typename Elem, std::size_t N, typename T, typename Elem, std::size_t N, typename T,
typename sprout::enabler_if<sprout::weed::traits::is_char_type<T>::value>::type = sprout::enabler typename sprout::enabler_if<sprout::is_char_type<T>::value>::type = sprout::enabler
> >
inline SPROUT_CONSTEXPR auto inline SPROUT_CONSTEXPR auto
eval(sprout::io::format_holder<T> const& holder) eval(sprout::io::format_holder<T> const& holder)

View file

@ -1,7 +1,7 @@
#ifndef SPROUT_ITERATOR_COUNTING_ITERATOR_HPP #ifndef SPROUT_ITERATOR_COUNTING_ITERATOR_HPP
#define SPROUT_ITERATOR_COUNTING_ITERATOR_HPP #define SPROUT_ITERATOR_COUNTING_ITERATOR_HPP
#include <cstddef> #include <limits>
#include <iterator> #include <iterator>
#include <utility> #include <utility>
#include <type_traits> #include <type_traits>
@ -34,7 +34,9 @@ namespace sprout {
value_type current_; value_type current_;
private: private:
public: public:
counting_iterator() = default; SPROUT_CONSTEXPR counting_iterator()
: current_(std::numeric_limits<value_type>::max())
{}
counting_iterator(counting_iterator const&) = default; counting_iterator(counting_iterator const&) = default;
explicit SPROUT_CONSTEXPR counting_iterator(value_type const& v) explicit SPROUT_CONSTEXPR counting_iterator(value_type const& v)
: current_(v) : current_(v)

View file

@ -10,6 +10,7 @@
#include <sprout/iterator.hpp> #include <sprout/iterator.hpp>
#include <sprout/iterator/value_iterator.hpp> #include <sprout/iterator/value_iterator.hpp>
#include <sprout/utility/forward.hpp> #include <sprout/utility/forward.hpp>
#include <sprout/array.hpp>
namespace sprout { namespace sprout {
// //
@ -210,6 +211,20 @@ namespace sprout {
> type; > type;
}; };
}; };
//
// blank
//
struct blank {};
//
// blank_pit
//
template<std::size_t N>
inline SPROUT_CONSTEXPR sprout::pit<sprout::array<sprout::blank, N> >
blank_pit() {
return sprout::pit<sprout::array<sprout::blank, N> >();
}
} // namespace sprout } // namespace sprout
namespace std { namespace std {

View file

@ -4,6 +4,7 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/range/adaptor/copied.hpp> #include <sprout/range/adaptor/copied.hpp>
#include <sprout/range/adaptor/transformed.hpp> #include <sprout/range/adaptor/transformed.hpp>
#include <sprout/range/adaptor/counting.hpp>
#include <sprout/range/adaptor/size_enumed.hpp> #include <sprout/range/adaptor/size_enumed.hpp>
#include <sprout/range/adaptor/sinusoidal.hpp> #include <sprout/range/adaptor/sinusoidal.hpp>

View file

@ -1,7 +1,6 @@
#ifndef SPROUT_RANGE_ADAPTOR_COUNTING_HPP #ifndef SPROUT_RANGE_ADAPTOR_COUNTING_HPP
#define SPROUT_RANGE_ADAPTOR_COUNTING_HPP #define SPROUT_RANGE_ADAPTOR_COUNTING_HPP
#include <limits>
#include <type_traits> #include <type_traits>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/pit.hpp> #include <sprout/pit.hpp>
@ -85,7 +84,7 @@ namespace sprout {
explicit SPROUT_CONSTEXPR counting_range(value_type const& first) explicit SPROUT_CONSTEXPR counting_range(value_type const& first)
: base_type( : base_type(
iterator(first), iterator(first),
iterator(std::numeric_limits<value_type>::max()) iterator()
) )
{} {}
SPROUT_CONSTEXPR counting_range( SPROUT_CONSTEXPR counting_range(

View file

@ -4,9 +4,10 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/type_traits/is_int.hpp> #include <sprout/type_traits/is_int.hpp>
#include <sprout/type_traits/is_uint.hpp> #include <sprout/type_traits/is_uint.hpp>
#include <sprout/type_traits/is_char_type.hpp>
#include <sprout/type_traits/is_c_str.hpp>
#include <sprout/type_traits/lvalue_reference.hpp> #include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/type_traits/const_reference.hpp> #include <sprout/type_traits/const_reference.hpp>
#include <sprout/type_traits/has_xxx.hpp> #include <sprout/type_traits/has_xxx.hpp>
#include <sprout/type_traits/inherit_if_xxx.hpp>
#endif // #ifndef SPROUT_TYPE_TRAITS_HPP #endif // #ifndef SPROUT_TYPE_TRAITS_HPP

View file

@ -0,0 +1,61 @@
#ifndef SPROUT_TYPE_TRAITS_IS_C_STR_HPP
#define SPROUT_TYPE_TRAITS_IS_C_STR_HPP
#include <type_traits>
#include <sprout/config.hpp>
namespace sprout {
//
// is_c_str
//
template<typename T>
struct is_c_str
: public std::false_type
{};
template<typename T>
struct is_c_str<T const>
: public sprout::is_c_str<T>
{};
template<typename T>
struct is_c_str<T volatile>
: public sprout::is_c_str<T>
{};
template<typename T>
struct is_c_str<T const volatile>
: public sprout::is_c_str<T>
{};
template<std::size_t N>
struct is_c_str<char[N]>
: public std::true_type
{};
template<std::size_t N>
struct is_c_str<wchar_t[N]>
: public std::true_type
{};
template<std::size_t N>
struct is_c_str<char16_t[N]>
: public std::true_type
{};
template<std::size_t N>
struct is_c_str<char32_t[N]>
: public std::true_type
{};
template<std::size_t N>
struct is_c_str<char const[N]>
: public std::true_type
{};
template<std::size_t N>
struct is_c_str<wchar_t const[N]>
: public std::true_type
{};
template<std::size_t N>
struct is_c_str<char16_t const[N]>
: public std::true_type
{};
template<std::size_t N>
struct is_c_str<char32_t const[N]>
: public std::true_type
{};
} // namespace sprout
#endif // #ifndef SPROUT_TYPE_TRAITS_IS_C_STR_HPP

View file

@ -0,0 +1,45 @@
#ifndef SPROUT_TYPE_TRAITS_IS_CHAR_TYPE_HPP
#define SPROUT_TYPE_TRAITS_IS_CHAR_TYPE_HPP
#include <type_traits>
#include <sprout/config.hpp>
namespace sprout {
//
// is_char_type
//
template<typename T>
struct is_char_type
: public std::false_type
{};
template<typename T>
struct is_char_type<T const>
: public sprout::is_char_type<T>
{};
template<typename T>
struct is_char_type<T volatile>
: public sprout::is_char_type<T>
{};
template<typename T>
struct is_char_type<T const volatile>
: public sprout::is_char_type<T>
{};
template<>
struct is_char_type<char>
: public std::true_type
{};
template<>
struct is_char_type<wchar_t>
: public std::true_type
{};
template<>
struct is_char_type<char16_t>
: public std::true_type
{};
template<>
struct is_char_type<char32_t>
: public std::true_type
{};
} // namespace sprout
#endif // #ifndef SPROUT_TYPE_TRAITS_IS_CHAR_TYPE_HPP

View file

@ -1,8 +1,8 @@
#ifndef SPROUT_WEED_TRAITS_TYPE_IS_C_STR_HPP #ifndef SPROUT_WEED_TRAITS_TYPE_IS_C_STR_HPP
#define SPROUT_WEED_TRAITS_TYPE_IS_C_STR_HPP #define SPROUT_WEED_TRAITS_TYPE_IS_C_STR_HPP
#include <type_traits>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/type_traits/is_c_str.hpp>
namespace sprout { namespace sprout {
namespace weed { namespace weed {
@ -12,51 +12,7 @@ namespace sprout {
// //
template<typename T> template<typename T>
struct is_c_str struct is_c_str
: public std::false_type : public sprout::is_c_str<T>
{};
template<typename T>
struct is_c_str<T const>
: public sprout::weed::traits::is_c_str<T>
{};
template<typename T>
struct is_c_str<T volatile>
: public sprout::weed::traits::is_c_str<T>
{};
template<typename T>
struct is_c_str<T const volatile>
: public sprout::weed::traits::is_c_str<T>
{};
template<std::size_t N>
struct is_c_str<char[N]>
: public std::true_type
{};
template<std::size_t N>
struct is_c_str<wchar_t[N]>
: public std::true_type
{};
template<std::size_t N>
struct is_c_str<char16_t[N]>
: public std::true_type
{};
template<std::size_t N>
struct is_c_str<char32_t[N]>
: public std::true_type
{};
template<std::size_t N>
struct is_c_str<char const[N]>
: public std::true_type
{};
template<std::size_t N>
struct is_c_str<wchar_t const[N]>
: public std::true_type
{};
template<std::size_t N>
struct is_c_str<char16_t const[N]>
: public std::true_type
{};
template<std::size_t N>
struct is_c_str<char32_t const[N]>
: public std::true_type
{}; {};
} // namespace traits } // namespace traits
} // namespace weed } // namespace weed

View file

@ -1,8 +1,8 @@
#ifndef SPROUT_WEED_TRAITS_TYPE_IS_CHAR_TYPE_HPP #ifndef SPROUT_WEED_TRAITS_TYPE_IS_CHAR_TYPE_HPP
#define SPROUT_WEED_TRAITS_TYPE_IS_CHAR_TYPE_HPP #define SPROUT_WEED_TRAITS_TYPE_IS_CHAR_TYPE_HPP
#include <type_traits>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/type_traits/is_char_type.hpp>
namespace sprout { namespace sprout {
namespace weed { namespace weed {
@ -12,35 +12,7 @@ namespace sprout {
// //
template<typename T> template<typename T>
struct is_char_type struct is_char_type
: public std::false_type : public sprout::is_char_type<T>
{};
template<typename T>
struct is_char_type<T const>
: public sprout::weed::traits::is_char_type<T>
{};
template<typename T>
struct is_char_type<T volatile>
: public sprout::weed::traits::is_char_type<T>
{};
template<typename T>
struct is_char_type<T const volatile>
: public sprout::weed::traits::is_char_type<T>
{};
template<>
struct is_char_type<char>
: public std::true_type
{};
template<>
struct is_char_type<wchar_t>
: public std::true_type
{};
template<>
struct is_char_type<char16_t>
: public std::true_type
{};
template<>
struct is_char_type<char32_t>
: public std::true_type
{}; {};
} // namespace traits } // namespace traits
} // namespace weed } // namespace weed