diff --git a/sprout/container/indexes.hpp b/sprout/container/indexes.hpp index e64890a0..ab88a7c2 100644 --- a/sprout/container/indexes.hpp +++ b/sprout/container/indexes.hpp @@ -3,6 +3,7 @@ #include #include +#include #include namespace sprout { @@ -12,7 +13,7 @@ namespace sprout { // template struct container_indexes - : public sprout::detail::make_index_tuple_helper< + : public sprout::detail::make_indexes_helper< sprout::index_range<0, sprout::container_traits::static_size> > {}; diff --git a/sprout/index_tuple.hpp b/sprout/index_tuple.hpp index 084095ef..f7e8b228 100644 --- a/sprout/index_tuple.hpp +++ b/sprout/index_tuple.hpp @@ -1,202 +1,11 @@ #ifndef SPROUT_INDEX_TUPLE_HPP #define SPROUT_INDEX_TUPLE_HPP -#include -#include #include - -namespace sprout { - // - // index_t - // - typedef std::ptrdiff_t index_t; - - // - // index_tuple - // - template - struct index_tuple { - public: - typedef index_tuple type; - }; - - // - // make_indexes - // - template - inline SPROUT_CONSTEXPR typename IndexTupleType::type make_indexes() { - return typename IndexTupleType::type(); - } - - namespace detail { - template - struct make_index_tuple_helper { - public: - typedef typename IndexTupleType::type type; - public: - static SPROUT_CONSTEXPR type make() { - return type(); - } - }; - } // namespace detail - - // - // index_range - // - namespace detail { - template - struct index_range_next; - template - struct index_range_next, Next> { - public: - typedef sprout::index_tuple type; - }; - - template - struct index_range_next2; - template - struct index_range_next2, Next, Tail> { - public: - typedef sprout::index_tuple type; - }; - - template - struct index_range_impl; - template - struct index_range_impl< - First, - Step, - N, - typename std::enable_if<(N == 0)>::type - > { - public: - typedef sprout::index_tuple<> type; - }; - template - struct index_range_impl< - First, - Step, - N, - typename std::enable_if<(N == 1)>::type - > { - public: - typedef sprout::index_tuple type; - }; - template - struct index_range_impl< - First, - Step, - N, - typename std::enable_if<(N > 1 && N % 2 == 0)>::type - > - : public sprout::detail::index_range_next< - typename sprout::detail::index_range_impl::type, - First + N / 2 * Step - > - {}; - template - struct index_range_impl< - First, - Step, - N, - typename std::enable_if<(N > 1 && N % 2 == 1)>::type - > - : public sprout::detail::index_range_next2< - typename sprout::detail::index_range_impl::type, - First + N / 2 * Step, - First + (N - 1) * Step - > - {}; - } // namespace detail - template - struct index_range - : public sprout::detail::make_index_tuple_helper< - sprout::detail::index_range_impl< - First, - Step, - ((Last - First) + (Step - 1)) / Step - > - > - {}; - - // - // index_n - // - namespace detail { - template - struct index_n_next; - template - struct index_n_next> { - public: - typedef sprout::index_tuple type; - }; - - template - struct index_n_next2; - template - struct index_n_next2, Tail> { - public: - typedef sprout::index_tuple type; - }; - - template - struct index_n_impl; - template - struct index_n_impl< - I, - N, - typename std::enable_if<(N == 0)>::type - > { - public: - typedef sprout::index_tuple<> type; - }; - template - struct index_n_impl< - I, - N, - typename std::enable_if<(N == 1)>::type - > { - public: - typedef sprout::index_tuple type; - }; - template - struct index_n_impl< - I, - N, - typename std::enable_if<(N > 1 && N % 2 == 0)>::type - > - : public sprout::detail::index_n_next< - typename sprout::detail::index_n_impl::type - > - {}; - template - struct index_n_impl< - I, - N, - typename std::enable_if<(N > 1 && N % 2 == 1)>::type - > - : public sprout::detail::index_n_next2< - typename sprout::detail::index_n_impl::type, - I - > - {}; - } // namespace detail - template - struct index_n - : public sprout::detail::make_index_tuple_helper< - sprout::detail::index_n_impl - > - {}; - - // - // pack_indexes - // - template - struct pack_indexes - : public sprout::detail::make_index_tuple_helper< - sprout::index_range<0, sizeof...(Args)> - > - {}; -} // namespace sprout +#include +#include +#include +#include +#include #endif // #ifndef SPROUT_INDEX_TUPLE_HPP diff --git a/sprout/index_tuple/detail/make_indexes_helper.hpp b/sprout/index_tuple/detail/make_indexes_helper.hpp new file mode 100644 index 00000000..30604190 --- /dev/null +++ b/sprout/index_tuple/detail/make_indexes_helper.hpp @@ -0,0 +1,20 @@ +#ifndef SPROUT_INDEX_TUPLE_DETAIL_MAKE_INDEXES_HELPER_HPP +#define SPROUT_INDEX_TUPLE_DETAIL_MAKE_INDEXES_HELPER_HPP + +#include + +namespace sprout { + namespace detail { + template + struct make_indexes_helper { + public: + typedef typename IndexTupleType::type type; + public: + static SPROUT_CONSTEXPR type make() { + return type(); + } + }; + } // namespace detail +} // namespace sprout + +#endif // #ifndef SPROUT_INDEX_TUPLE_DETAIL_MAKE_INDEXES_HELPER_HPP diff --git a/sprout/index_tuple/index_n.hpp b/sprout/index_tuple/index_n.hpp new file mode 100644 index 00000000..32424971 --- /dev/null +++ b/sprout/index_tuple/index_n.hpp @@ -0,0 +1,81 @@ +#ifndef SPROUT_INDEX_TUPLE_INDEX_N_HPP +#define SPROUT_INDEX_TUPLE_INDEX_N_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + // + // index_n + // + namespace detail { + template + struct index_n_next; + template + struct index_n_next> { + public: + typedef sprout::index_tuple type; + }; + + template + struct index_n_next2; + template + struct index_n_next2, Tail> { + public: + typedef sprout::index_tuple type; + }; + + template + struct index_n_impl; + template + struct index_n_impl< + I, + N, + typename std::enable_if<(N == 0)>::type + > { + public: + typedef sprout::index_tuple<> type; + }; + template + struct index_n_impl< + I, + N, + typename std::enable_if<(N == 1)>::type + > { + public: + typedef sprout::index_tuple type; + }; + template + struct index_n_impl< + I, + N, + typename std::enable_if<(N > 1 && N % 2 == 0)>::type + > + : public sprout::detail::index_n_next< + typename sprout::detail::index_n_impl::type + > + {}; + template + struct index_n_impl< + I, + N, + typename std::enable_if<(N > 1 && N % 2 == 1)>::type + > + : public sprout::detail::index_n_next2< + typename sprout::detail::index_n_impl::type, + I + > + {}; + } // namespace detail + template + struct index_n + : public sprout::detail::make_indexes_helper< + sprout::detail::index_n_impl + > + {}; +} // namespace sprout + +#endif // #ifndef SPROUT_INDEX_TUPLE_INDEX_N_HPP diff --git a/sprout/index_tuple/index_range.hpp b/sprout/index_tuple/index_range.hpp new file mode 100644 index 00000000..d7cc57b4 --- /dev/null +++ b/sprout/index_tuple/index_range.hpp @@ -0,0 +1,91 @@ +#ifndef SPROUT_INDEX_TUPLE_INDEX_RANGE_HPP +#define SPROUT_INDEX_TUPLE_INDEX_RANGE_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + // + // index_range + // + namespace detail { + template + struct index_range_next; + template + struct index_range_next, Next> { + public: + typedef sprout::index_tuple type; + }; + + template + struct index_range_next2; + template + struct index_range_next2, Next, Tail> { + public: + typedef sprout::index_tuple type; + }; + + template + struct index_range_impl; + template + struct index_range_impl< + First, + Step, + N, + typename std::enable_if<(N == 0)>::type + > { + public: + typedef sprout::index_tuple<> type; + }; + template + struct index_range_impl< + First, + Step, + N, + typename std::enable_if<(N == 1)>::type + > { + public: + typedef sprout::index_tuple type; + }; + template + struct index_range_impl< + First, + Step, + N, + typename std::enable_if<(N > 1 && N % 2 == 0)>::type + > + : public sprout::detail::index_range_next< + typename sprout::detail::index_range_impl::type, + First + N / 2 * Step + > + {}; + template + struct index_range_impl< + First, + Step, + N, + typename std::enable_if<(N > 1 && N % 2 == 1)>::type + > + : public sprout::detail::index_range_next2< + typename sprout::detail::index_range_impl::type, + First + N / 2 * Step, + First + (N - 1) * Step + > + {}; + } // namespace detail + template + struct index_range + : public sprout::detail::make_indexes_helper< + sprout::detail::index_range_impl< + First, + Step, + ((Last - First) + (Step - 1)) / Step + > + > + {}; +} // namespace sprout + +#endif // #ifndef SPROUT_INDEX_TUPLE_INDEX_RANGE_HPP diff --git a/sprout/index_tuple/index_tuple.hpp b/sprout/index_tuple/index_tuple.hpp new file mode 100644 index 00000000..0afcc9b3 --- /dev/null +++ b/sprout/index_tuple/index_tuple.hpp @@ -0,0 +1,23 @@ +#ifndef SPROUT_INDEX_TUPLE_INDEX_TUPLE_HPP +#define SPROUT_INDEX_TUPLE_INDEX_TUPLE_HPP + +#include +#include + +namespace sprout { + // + // index_t + // + typedef std::ptrdiff_t index_t; + + // + // index_tuple + // + template + struct index_tuple { + public: + typedef index_tuple type; + }; +} // namespace sprout + +#endif // #ifndef SPROUT_INDEX_TUPLE_INDEX_TUPLE_HPP diff --git a/sprout/index_tuple/make_indexes.hpp b/sprout/index_tuple/make_indexes.hpp new file mode 100644 index 00000000..9a74478d --- /dev/null +++ b/sprout/index_tuple/make_indexes.hpp @@ -0,0 +1,16 @@ +#ifndef SPROUT_INDEX_TUPLE_MAKE_INDEXES_HPP +#define SPROUT_INDEX_TUPLE_MAKE_INDEXES_HPP + +#include + +namespace sprout { + // + // make_indexes + // + template + inline SPROUT_CONSTEXPR typename IndexTupleType::type make_indexes() { + return typename IndexTupleType::type(); + } +} // namespace sprout + +#endif // #ifndef SPROUT_INDEX_TUPLE_MAKE_INDEXES_HPP diff --git a/sprout/index_tuple/pack_indexes.hpp b/sprout/index_tuple/pack_indexes.hpp new file mode 100644 index 00000000..57f92947 --- /dev/null +++ b/sprout/index_tuple/pack_indexes.hpp @@ -0,0 +1,19 @@ +#ifndef SPROUT_INDEX_TUPLE_PACK_INDEXES_HPP +#define SPROUT_INDEX_TUPLE_PACK_INDEXES_HPP + +#include +#include + +namespace sprout { + // + // pack_indexes + // + template + struct pack_indexes + : public sprout::detail::make_indexes_helper< + sprout::index_range<0, sizeof...(Args)> + > + {}; +} // namespace sprout + +#endif // #ifndef SPROUT_INDEX_TUPLE_PACK_INDEXES_HPP diff --git a/sprout/tuple/indexes.hpp b/sprout/tuple/indexes.hpp index 6fcca841..e6fb7a55 100644 --- a/sprout/tuple/indexes.hpp +++ b/sprout/tuple/indexes.hpp @@ -3,6 +3,7 @@ #include #include +#include #include namespace sprout { @@ -12,7 +13,7 @@ namespace sprout { // template struct tuple_indexes - : public sprout::detail::make_index_tuple_helper< + : public sprout::detail::make_indexes_helper< sprout::index_range<0, sprout::tuples::tuple_size::value> > {}; diff --git a/sprout_user_config.hpp b/sprout_user_config.hpp deleted file mode 100644 index 39de7908..00000000 --- a/sprout_user_config.hpp +++ /dev/null @@ -1,7 +0,0 @@ - -//#define SPROUT_CONFIG_DISABLE_CONSTEXPR -//#define SPROUT_CONFIG_DISABLE_NOEXCEPT -//#define SPROUT_CONFIG_DISABLE_TEMPLATE_ALIASES -//#define SPROUT_CONFIG_USE_SSCRISK_CEL -//#define SPROUT_CONFIG_DISABLE_SUPPORT_TEMPORARY_CONTAINER_ITERATION -//#define SPROUT_CONFIG_SUPPORT_TEMPORARY_CONTAINER_ITERATION