From a7b415f2b139b34684915943ca4a946735080604 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Mon, 31 Oct 2011 17:31:03 +0900 Subject: [PATCH] =?UTF-8?q?tuple/*=20=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sprout/functional/hash/uuid.hpp | 15 ++++ sprout/tuple/array.hpp | 32 +++++++ sprout/tuple/sscrisk/cel/array.hpp | 32 +++++++ sprout/tuple/string.hpp | 32 +++++++ sprout/tuple/tuple.hpp | 131 +++++++++++++---------------- sprout/tuple/uuid.hpp | 32 +++++++ sprout/uuid/uuid_hash.hpp | 9 +- 7 files changed, 202 insertions(+), 81 deletions(-) create mode 100644 sprout/functional/hash/uuid.hpp create mode 100644 sprout/tuple/array.hpp create mode 100644 sprout/tuple/sscrisk/cel/array.hpp create mode 100644 sprout/tuple/string.hpp create mode 100644 sprout/tuple/uuid.hpp diff --git a/sprout/functional/hash/uuid.hpp b/sprout/functional/hash/uuid.hpp new file mode 100644 index 00000000..5b70ce27 --- /dev/null +++ b/sprout/functional/hash/uuid.hpp @@ -0,0 +1,15 @@ +#ifndef SPROUT_FUNCTIONAL_HASH_UUID_HPP +#define SPROUT_FUNCTIONAL_HASH_UUID_HPP + +#include +#include +#include +#include + +namespace sprout { + SPROUT_CONSTEXPR std::size_t hash_value(sprout::uuids::uuid const& v) { + return sprout::hash_range(v.begin(), v.end()); + } +} // namespace sprout + +#endif // #ifndef SPROUT_FUNCTIONAL_HASH_UUID_HPP diff --git a/sprout/tuple/array.hpp b/sprout/tuple/array.hpp new file mode 100644 index 00000000..102f6852 --- /dev/null +++ b/sprout/tuple/array.hpp @@ -0,0 +1,32 @@ +#ifndef SPROUT_TUPLE_ARRAY_HPP +#define SPROUT_TUPLE_ARRAY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace tuples { + // + // get + // + template + T& get(sprout::array& t) SPROUT_NOEXCEPT { + static_assert(I < N, "get: index out of range"); + return t[I]; + } + template + SPROUT_CONSTEXPR T const& get(sprout::array const& t) SPROUT_NOEXCEPT { + static_assert(I < N, "get: index out of range"); + return t[I]; + } + template + T&& get(sprout::array&& t) SPROUT_NOEXCEPT { + return std::move(sprout::tuples::get(t)); + } + } // namespace tuples +} // namespace sprout + +#endif // #ifndef SPROUT_TUPLE_TUPLE_COMPARISON_HPP diff --git a/sprout/tuple/sscrisk/cel/array.hpp b/sprout/tuple/sscrisk/cel/array.hpp new file mode 100644 index 00000000..1cf94747 --- /dev/null +++ b/sprout/tuple/sscrisk/cel/array.hpp @@ -0,0 +1,32 @@ +#ifndef SPROUT_TUPLE_SSCRISK_CEL_ARRAY_HPP +#define SPROUT_TUPLE_SSCRISK_CEL_ARRAY_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace tuples { + // + // get + // + template + T& get(sscrisk::cel::array& t) SPROUT_NOEXCEPT { + static_assert(I < N, "get: index out of range"); + return t[I]; + } + template + SPROUT_CONSTEXPR T const& get(sscrisk::cel::array const& t) SPROUT_NOEXCEPT { + static_assert(I < N, "get: index out of range"); + return t[I]; + } + template + T&& get(sscrisk::cel::array&& t) SPROUT_NOEXCEPT { + return std::move(sprout::tuples::get(t)); + } + } // namespace tuples +} // namespace sprout + +#endif // #ifndef SPROUT_TUPLE_SSCRISK_CEL_ARRAY_HPP diff --git a/sprout/tuple/string.hpp b/sprout/tuple/string.hpp new file mode 100644 index 00000000..9f49315f --- /dev/null +++ b/sprout/tuple/string.hpp @@ -0,0 +1,32 @@ +#ifndef SPROUT_TUPLE_STRING_HPP +#define SPROUT_TUPLE_STRING_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace tuples { + // + // get + // + template + T& get(sprout::basic_string& t) SPROUT_NOEXCEPT { + static_assert(I < N, "get: index out of range"); + return t[I]; + } + template + SPROUT_CONSTEXPR T const& get(sprout::basic_string const& t) SPROUT_NOEXCEPT { + static_assert(I < N, "get: index out of range"); + return t[I]; + } + template + T&& get(sprout::basic_string&& t) SPROUT_NOEXCEPT { + return std::move(sprout::tuples::get(t)); + } + } // namespace tuples +} // namespace sprout + +#endif // #ifndef SPROUT_TUPLE_STRING_HPP diff --git a/sprout/tuple/tuple.hpp b/sprout/tuple/tuple.hpp index 4c7d6517..3441cf0d 100644 --- a/sprout/tuple/tuple.hpp +++ b/sprout/tuple/tuple.hpp @@ -261,48 +261,6 @@ namespace sprout { return sprout::tuples::tuple(args...); } - // - // tuple_size - // - template - struct tuple_size; - template - struct tuple_size - : public sprout::tuples::tuple_size - {}; - template - struct tuple_size - : public sprout::tuples::tuple_size - {}; - template - struct tuple_size - : public sprout::tuples::tuple_size - {}; - template - struct tuple_size > - : public std::integral_constant - {}; - - // - // tuple_element - // - template - struct tuple_element; - template - struct tuple_element { - public: - typedef typename std::add_const::type>::type type; - }; - template - struct tuple_element { - public: - typedef typename std::add_volatile::type>::type type; - }; - template - struct tuple_element { - public: - typedef typename std::add_cv::type>::type type; - }; namespace detail { template struct tuple_element_impl; @@ -313,14 +271,64 @@ namespace sprout { }; template struct tuple_element_impl > - : public sprout::tuples::tuple_element > + : public sprout::tuples::detail::tuple_element_impl > {}; } // namespace detail - template - struct tuple_element > - : public sprout::tuples::detail::tuple_element_impl > + } // namespace tuples + + using sprout::tuples::tuple; + using sprout::tuples::ignore; + using sprout::tuples::make_tuple; + using sprout::tuples::forward_as_tuple; + using sprout::tuples::tie; +} // namespace sprout + +namespace std { + // + // tuple_size + // + template + struct tuple_size > + : public std::integral_constant + {}; + + // + // tuple_element + // + template + struct tuple_element > + : public sprout::tuples::detail::tuple_element_impl > + {}; +} // namespace std + +namespace sprout { + namespace tuples { + // + // tuple_size + // + template + struct tuple_size + : public std::tuple_size {}; + // + // tuple_element + // + template + struct tuple_element + : public std::tuple_element + {}; + + // + // get + // + template + SPROUT_CONSTEXPR auto get( + T&& t + ) SPROUT_NOEXCEPT -> decltype(std::get(sprout::forward(t))) + { + return std::get(sprout::forward(t)); + } // // get // @@ -342,23 +350,23 @@ namespace sprout { } // namespace detail template SPROUT_CONSTEXPR typename sprout::tuples::tuple_element >::type& get( - tuple& t + sprout::tuples::tuple& t ) SPROUT_NOEXCEPT { return sprout::tuples::detail::get_helper(t); } template SPROUT_CONSTEXPR typename sprout::tuples::tuple_element >::type&& get( - tuple&& t + sprout::tuples::tuple&& t ) SPROUT_NOEXCEPT { - return sprout::forward >::type&&>( + return sprout::forward >::type&&>( sprout::tuples::get(t) ); } template SPROUT_CONSTEXPR typename sprout::tuples::tuple_element >::type const& get( - tuple const& t + sprout::tuples::tuple const& t ) SPROUT_NOEXCEPT { return sprout::tuples::detail::get_helper(t); @@ -373,33 +381,10 @@ namespace sprout { } } // namespace tuples - using sprout::tuples::tuple; - using sprout::tuples::ignore; - using sprout::tuples::make_tuple; - using sprout::tuples::forward_as_tuple; - using sprout::tuples::tie; using sprout::tuples::tuple_size; using sprout::tuples::tuple_element; using sprout::tuples::get; using sprout::tuples::swap; } // namespace sprout -namespace std { - // - // tuple_size - // - template - struct tuple_size > - : public sprout::tuples::tuple_size > - {}; - - // - // tuple_element - // - template - struct tuple_element > - : public sprout::tuples::tuple_element > - {}; -} // namespace std - #endif // #ifndef SPROUT_TUPLE_TUPLE_HPP diff --git a/sprout/tuple/uuid.hpp b/sprout/tuple/uuid.hpp new file mode 100644 index 00000000..e6800159 --- /dev/null +++ b/sprout/tuple/uuid.hpp @@ -0,0 +1,32 @@ +#ifndef SPROUT_TUPLE_UUID_HPP +#define SPROUT_TUPLE_UUID_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace tuples { + // + // get + // + template + sprout::uuids::uuid::value_type& get(sprout::uuids::uuid& t) SPROUT_NOEXCEPT { + static_assert(I < 16, "get: index out of range"); + return t[I]; + } + template + SPROUT_CONSTEXPR sprout::uuids::uuid::value_type const& get(sprout::uuids::uuid const& t) SPROUT_NOEXCEPT { + static_assert(I < 16, "get: index out of range"); + return t[I]; + } + template + sprout::uuids::uuid::value_type&& get(sprout::uuids::uuid&& t) SPROUT_NOEXCEPT { + return std::move(std::get(t)); + } + } // namespace tuples +} // namespace sprout + +#endif // #ifndef SPROUT_TUPLE_UUID_HPP diff --git a/sprout/uuid/uuid_hash.hpp b/sprout/uuid/uuid_hash.hpp index bdae3f09..e8c40c94 100644 --- a/sprout/uuid/uuid_hash.hpp +++ b/sprout/uuid/uuid_hash.hpp @@ -2,13 +2,6 @@ #define SPROUT_UUID_UUID_HASH_HPP #include -#include -#include - -namespace sprout { - SPROUT_CONSTEXPR std::size_t hash_value(sprout::uuids::uuid const& v) { - return sprout::hash_range(v.begin(), v.end()); - } -} // namespace sprout +#include #endif // #ifndef SPROUT_UUID_UUID_HASH_HPP