From 64dd2582a4cfe85ad65fed66d7361a4dc8688023 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Thu, 5 Apr 2012 14:54:23 +0900 Subject: [PATCH] add type_traits/* --- sprout/range/algorithm/equal_range.hpp | 8 ++--- sprout/range/algorithm/mismatch.hpp | 10 +++---- sprout/range/lvalue_iterator.hpp | 24 +++++++++++++++ .../{lvref_range.hpp => lvalue_range.hpp} | 14 ++++----- sprout/range/lvref_iterator.hpp | 24 --------------- sprout/range/range_return.hpp | 10 +++---- sprout/type_traits.hpp | 8 +++++ sprout/type_traits/const_reference.hpp | 19 ++++++++++++ sprout/type_traits/lvalue_reference.hpp | 19 ++++++++++++ sprout/utility.hpp | 3 +- sprout/utility/as_lvalue.hpp | 20 +++++++++++++ sprout/utility/as_lvref.hpp | 29 ------------------- sprout/utility/operation_ext.hpp | 2 +- 13 files changed, 114 insertions(+), 76 deletions(-) create mode 100644 sprout/range/lvalue_iterator.hpp rename sprout/range/{lvref_range.hpp => lvalue_range.hpp} (50%) delete mode 100644 sprout/range/lvref_iterator.hpp create mode 100644 sprout/type_traits.hpp create mode 100644 sprout/type_traits/const_reference.hpp create mode 100644 sprout/type_traits/lvalue_reference.hpp create mode 100644 sprout/utility/as_lvalue.hpp delete mode 100644 sprout/utility/as_lvref.hpp diff --git a/sprout/range/algorithm/equal_range.hpp b/sprout/range/algorithm/equal_range.hpp index 9a7662b2..8f5f10a6 100644 --- a/sprout/range/algorithm/equal_range.hpp +++ b/sprout/range/algorithm/equal_range.hpp @@ -4,14 +4,14 @@ #include #include #include -#include +#include #include namespace sprout { namespace range { namespace detail { template - inline SPROUT_CONSTEXPR typename sprout::range::lvref_range::type + inline SPROUT_CONSTEXPR typename sprout::range::lvalue_range::type pair_to_range(Pair const& pair) { return {pair.first, pair.second}; } @@ -21,7 +21,7 @@ namespace sprout { // 25.4.3.3 equal_range template - inline SPROUT_CONSTEXPR typename sprout::range::lvref_range::type + inline SPROUT_CONSTEXPR typename sprout::range::lvalue_range::type equal_range(Range&& range, T const& value) { return sprout::range::detail::pair_to_range( sprout::equal_range( @@ -33,7 +33,7 @@ namespace sprout { } template - inline SPROUT_CONSTEXPR typename sprout::range::lvref_range::type + inline SPROUT_CONSTEXPR typename sprout::range::lvalue_range::type equal_range(Range&& range, T const& value, Compare comp) { return sprout::range::detail::pair_to_range( sprout::equal_range( diff --git a/sprout/range/algorithm/mismatch.hpp b/sprout/range/algorithm/mismatch.hpp index 9dae09dd..4dc7edbd 100644 --- a/sprout/range/algorithm/mismatch.hpp +++ b/sprout/range/algorithm/mismatch.hpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include namespace sprout { @@ -15,8 +15,8 @@ namespace sprout { // 25.2.10 Mismatch template inline SPROUT_CONSTEXPR sprout::pair< - typename sprout::range::lvref_iterator::type, - typename sprout::range::lvref_iterator::type + typename sprout::range::lvalue_iterator::type, + typename sprout::range::lvalue_iterator::type > mismatch(Range1&& range1, Range2&& range2) { return sprout::mismatch( @@ -28,8 +28,8 @@ namespace sprout { template inline SPROUT_CONSTEXPR sprout::pair< - typename sprout::range::lvref_iterator::type, - typename sprout::range::lvref_iterator::type + typename sprout::range::lvalue_iterator::type, + typename sprout::range::lvalue_iterator::type > mismatch(Range1&& range1, Range2&& range2, BinaryPredicate pred) { return sprout::mismatch( diff --git a/sprout/range/lvalue_iterator.hpp b/sprout/range/lvalue_iterator.hpp new file mode 100644 index 00000000..817f20ae --- /dev/null +++ b/sprout/range/lvalue_iterator.hpp @@ -0,0 +1,24 @@ +#ifndef SPROUT_RANGE_LVALUE_ITERATOR_HPP +#define SPROUT_RANGE_LVALUE_ITERATOR_HPP + +#include +#include +#include +#include + +namespace sprout { + namespace range { + // + // lvalue_iterator + // + template + struct lvalue_iterator { + public: + typedef typename sprout::container_traits< + typename std::remove_reference::type>::type + >::iterator type; + }; + } // namespace range +} // namespace sprout + +#endif // #ifndef SPROUT_RANGE_LVALUE_ITERATOR_HPP diff --git a/sprout/range/lvref_range.hpp b/sprout/range/lvalue_range.hpp similarity index 50% rename from sprout/range/lvref_range.hpp rename to sprout/range/lvalue_range.hpp index ec7b3302..05cbd36f 100644 --- a/sprout/range/lvref_range.hpp +++ b/sprout/range/lvalue_range.hpp @@ -1,21 +1,21 @@ -#ifndef SPROUT_RANGE_LVREF_RANGE_HPP -#define SPROUT_RANGE_LVREF_RANGE_HPP +#ifndef SPROUT_RANGE_LVALUE_RANGE_HPP +#define SPROUT_RANGE_LVALUE_RANGE_HPP #include #include -#include +#include namespace sprout { namespace range { // - // lvref_range + // lvalue_range // template - struct lvref_range { + struct lvalue_range { public: - typedef sprout::range::range_container::type> type; + typedef sprout::range::range_container::type> type; }; } // namespace range } // namespace sprout -#endif // #ifndef SPROUT_RANGE_LVREF_RANGE_HPP +#endif // #ifndef SPROUT_RANGE_LVALUE_RANGE_HPP diff --git a/sprout/range/lvref_iterator.hpp b/sprout/range/lvref_iterator.hpp deleted file mode 100644 index ce09aec6..00000000 --- a/sprout/range/lvref_iterator.hpp +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef SPROUT_RANGE_LVREF_ITERATOR_HPP -#define SPROUT_RANGE_LVREF_ITERATOR_HPP - -#include -#include -#include -#include - -namespace sprout { - namespace range { - // - // lvref_iterator - // - template - struct lvref_iterator { - public: - typedef typename sprout::container_traits< - typename std::remove_reference::type>::type - >::iterator type; - }; - } // namespace range -} // namespace sprout - -#endif // #ifndef SPROUT_RANGE_LVREF_ITERATOR_HPP diff --git a/sprout/range/range_return.hpp b/sprout/range/range_return.hpp index b1fea3ea..b680be59 100644 --- a/sprout/range/range_return.hpp +++ b/sprout/range/range_return.hpp @@ -5,8 +5,8 @@ #include #include #include -#include -#include +#include +#include namespace sprout { namespace range { @@ -28,7 +28,7 @@ namespace sprout { template struct range_return { public: - typedef typename sprout::range::lvref_iterator::type type; + typedef typename sprout::range::lvalue_iterator::type type; public: static SPROUT_CONSTEXPR type pack( typename sprout::container_traits::iterator found, @@ -41,7 +41,7 @@ namespace sprout { template struct range_return { public: - typedef typename sprout::range::lvref_range::type type; + typedef typename sprout::range::lvalue_range::type type; public: static SPROUT_CONSTEXPR type pack( typename sprout::container_traits::iterator found, @@ -54,7 +54,7 @@ namespace sprout { template struct range_return { public: - typedef typename sprout::range::lvref_range::type type; + typedef typename sprout::range::lvalue_range::type type; public: static SPROUT_CONSTEXPR type pack( typename sprout::container_traits::iterator found, diff --git a/sprout/type_traits.hpp b/sprout/type_traits.hpp new file mode 100644 index 00000000..51df19f4 --- /dev/null +++ b/sprout/type_traits.hpp @@ -0,0 +1,8 @@ +#ifndef SPROUT_TYPE_TRAITS_HPP +#define SPROUT_TYPE_TRAITS_HPP + +#include +#include +#include + +#endif // #ifndef SPROUT_TYPE_TRAITS_HPP diff --git a/sprout/type_traits/const_reference.hpp b/sprout/type_traits/const_reference.hpp new file mode 100644 index 00000000..ecb17aa5 --- /dev/null +++ b/sprout/type_traits/const_reference.hpp @@ -0,0 +1,19 @@ +#ifndef SPROUT_TYPE_TRAITS_CONST_REFERENCE_HPP +#define SPROUT_TYPE_TRAITS_CONST_REFERENCE_HPP + +#include +#include +#include + +namespace sprout { + // + // const_reference + // + template + struct const_reference { + public: + typedef decltype(sprout::as_const(std::declval())) type; + }; +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_CONST_REFERENCE_HPP diff --git a/sprout/type_traits/lvalue_reference.hpp b/sprout/type_traits/lvalue_reference.hpp new file mode 100644 index 00000000..7a0b1c62 --- /dev/null +++ b/sprout/type_traits/lvalue_reference.hpp @@ -0,0 +1,19 @@ +#ifndef SPROUT_TYPE_TRAITS_LVALUE_REFERENCE_HPP +#define SPROUT_TYPE_TRAITS_LVALUE_REFERENCE_HPP + +#include +#include +#include + +namespace sprout { + // + // lvalue_reference + // + template + struct lvalue_reference { + public: + typedef decltype(sprout::as_lvalue(std::declval())) type; + }; +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_LVALUE_REFERENCE_HPP diff --git a/sprout/utility.hpp b/sprout/utility.hpp index 9bacae00..f0f83a14 100644 --- a/sprout/utility.hpp +++ b/sprout/utility.hpp @@ -2,7 +2,8 @@ #define SPROUT_UTILITY_HPP #include -#include #include +#include +#include #endif // #ifndef SPROUT_UTILITY_HPP diff --git a/sprout/utility/as_lvalue.hpp b/sprout/utility/as_lvalue.hpp new file mode 100644 index 00000000..7f316f12 --- /dev/null +++ b/sprout/utility/as_lvalue.hpp @@ -0,0 +1,20 @@ +#ifndef SPROUT_UTILITY_AS_LVALUE_HPP +#define SPROUT_UTILITY_AS_LVALUE_HPP + +#include + +namespace sprout { + // + // as_lvalue + // + template + inline T& as_lvalue(T& t) { + return t; + } + template + inline SPROUT_CONSTEXPR T const& as_lvalue(T const& t) { + return t; + } +} // namespace sprout + +#endif // #ifndef SPROUT_UTILITY_AS_LVALUE_HPP diff --git a/sprout/utility/as_lvref.hpp b/sprout/utility/as_lvref.hpp deleted file mode 100644 index e2bada45..00000000 --- a/sprout/utility/as_lvref.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef SPROUT_UTILITY_AS_LVREF_HPP -#define SPROUT_UTILITY_AS_LVREF_HPP - -#include - -namespace sprout { - // - // as_lvref - // - template - inline T& as_lvref(T& t) { - return t; - } - template - inline SPROUT_CONSTEXPR T const& as_lvref(T const& t) { - return t; - } - - // - // lvref - // - template - struct lvref { - public: - typedef decltype(sprout::as_lvref(std::declval())) type; - }; -} // namespace sprout - -#endif // #ifndef SPROUT_UTILITY_AS_LVREF_HPP diff --git a/sprout/utility/operation_ext.hpp b/sprout/utility/operation_ext.hpp index 037c2cc1..ad064555 100644 --- a/sprout/utility/operation_ext.hpp +++ b/sprout/utility/operation_ext.hpp @@ -2,7 +2,7 @@ #define SPROUT_UTILITY_OPERATION_EXT_HPP #include -#include +#include #include #endif // #ifndef SPROUT_UTILITY_OPERATION_EXT_HPP