From 2614c4e3f9d510f04a69a278d5016919a080bba6 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Fri, 15 Sep 2017 19:08:49 +0900 Subject: [PATCH] add type tuple algorithms and C++17 type traits --- sprout/type/algorithm.hpp | 8 + sprout/type/algorithm/all_of.hpp | 80 +++++++ sprout/type/algorithm/all_of_same.hpp | 79 ++++++ sprout/type/algorithm/any_of.hpp | 80 +++++++ sprout/type/algorithm/any_of_same.hpp | 79 ++++++ sprout/type/algorithm/contains.hpp | 4 +- sprout/type/algorithm/contains_if.hpp | 4 +- sprout/type/algorithm/none_of.hpp | 80 +++++++ sprout/type/algorithm/none_of_same.hpp | 79 ++++++ sprout/type/algorithm/one_of.hpp | 115 +++++++++ sprout/type/algorithm/one_of_same.hpp | 114 +++++++++ .../has_unique_object_representations.hpp | 41 ++++ sprout/type_traits/invoke_result.hpp | 29 +++ sprout/type_traits/is_aggregate.hpp | 41 ++++ sprout/type_traits/property.hpp | 2 + sprout/type_traits/result_of.hpp | 224 +++--------------- sprout/type_traits/transformation.hpp | 1 + tools/darkroom/darkcult.sh | 26 +- tools/testspr/test.sh | 2 +- 19 files changed, 883 insertions(+), 205 deletions(-) create mode 100644 sprout/type/algorithm/all_of.hpp create mode 100644 sprout/type/algorithm/all_of_same.hpp create mode 100644 sprout/type/algorithm/any_of.hpp create mode 100644 sprout/type/algorithm/any_of_same.hpp create mode 100644 sprout/type/algorithm/none_of.hpp create mode 100644 sprout/type/algorithm/none_of_same.hpp create mode 100644 sprout/type/algorithm/one_of.hpp create mode 100644 sprout/type/algorithm/one_of_same.hpp create mode 100644 sprout/type_traits/has_unique_object_representations.hpp create mode 100644 sprout/type_traits/invoke_result.hpp create mode 100644 sprout/type_traits/is_aggregate.hpp diff --git a/sprout/type/algorithm.hpp b/sprout/type/algorithm.hpp index 0470525b..e1cb7f78 100644 --- a/sprout/type/algorithm.hpp +++ b/sprout/type/algorithm.hpp @@ -9,6 +9,14 @@ #define SPROUT_TYPE_ALGORITHM_HPP #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/sprout/type/algorithm/all_of.hpp b/sprout/type/algorithm/all_of.hpp new file mode 100644 index 00000000..e30c05a7 --- /dev/null +++ b/sprout/type/algorithm/all_of.hpp @@ -0,0 +1,80 @@ +/*============================================================================= + Copyright (c) 2011-2017 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_TYPE_ALGORITHM_ALL_OF_HPP +#define SPROUT_TYPE_ALGORITHM_ALL_OF_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace types { + namespace detail { + template< + typename Tuple, typename Predicate, std::size_t First, std::size_t Last, + std::size_t Pivot, + bool C1 = (Pivot == 0) + > + struct all_of_impl; + template< + typename Tuple, typename Predicate, std::size_t First, std::size_t Last, + std::size_t Pivot + > + struct all_of_impl + : public sprout::bool_constant< + sprout::types::apply::type>::type::value + > + {}; + template< + typename Tuple, typename Predicate, std::size_t First, std::size_t Last, + std::size_t Pivot + > + struct all_of_impl + : public sprout::bool_constant< + sprout::types::detail::all_of_impl< + Tuple, Predicate, First, First + Pivot, + Pivot / 2 + >::value + && sprout::types::detail::all_of_impl< + Tuple, Predicate, First + Pivot, Last, + (Last - First - Pivot) / 2 + >::value + > + {}; + template::value> + struct all_of + : public sprout::types::detail::all_of_impl + {}; + template + struct all_of + : public sprout::true_type + {}; + } // namespace detail + // + // all_of + // + template + struct all_of + : public sprout::types::detail::all_of + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using all_of_t = typename sprout::types::all_of::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES + +#if SPROUT_USE_VARIABLE_TEMPLATES + template + SPROUT_STATIC_CONSTEXPR bool all_of_v = sprout::types::all_of::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES + } // namespace types +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_ALGORITHM_ALL_OF_HPP diff --git a/sprout/type/algorithm/all_of_same.hpp b/sprout/type/algorithm/all_of_same.hpp new file mode 100644 index 00000000..5d6abc96 --- /dev/null +++ b/sprout/type/algorithm/all_of_same.hpp @@ -0,0 +1,79 @@ +/*============================================================================= + Copyright (c) 2011-2017 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_TYPE_ALGORITHM_ALL_OF_SAME_HPP +#define SPROUT_TYPE_ALGORITHM_ALL_OF_SAME_HPP + +#include +#include +#include +#include + +namespace sprout { + namespace types { + namespace detail { + template< + typename Tuple, typename T, std::size_t First, std::size_t Last, + std::size_t Pivot, + bool C1 = (Pivot == 0) + > + struct all_of_same_impl; + template< + typename Tuple, typename T, std::size_t First, std::size_t Last, + std::size_t Pivot + > + struct all_of_same_impl + : public sprout::bool_constant< + std::is_same::type, T>::value + > + {}; + template< + typename Tuple, typename T, std::size_t First, std::size_t Last, + std::size_t Pivot + > + struct all_of_same_impl + : public sprout::bool_constant< + sprout::types::detail::all_of_same_impl< + Tuple, T, First, First + Pivot, + Pivot / 2 + >::value + && sprout::types::detail::all_of_same_impl< + Tuple, T, First + Pivot, Last, + (Last - First - Pivot) / 2 + >::value + > + {}; + template::value> + struct all_of_same + : public sprout::types::detail::all_of_same_impl + {}; + template + struct all_of_same + : public sprout::true_type + {}; + } // namespace detail + // + // all_of_same + // + template + struct all_of_same + : public sprout::types::detail::all_of_same + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using all_of_same_t = typename sprout::types::all_of_same::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES + +#if SPROUT_USE_VARIABLE_TEMPLATES + template + SPROUT_STATIC_CONSTEXPR bool all_of_same_v = sprout::types::all_of_same::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES + } // namespace types +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_ALGORITHM_ALL_OF_SAME_HPP diff --git a/sprout/type/algorithm/any_of.hpp b/sprout/type/algorithm/any_of.hpp new file mode 100644 index 00000000..3db6bd84 --- /dev/null +++ b/sprout/type/algorithm/any_of.hpp @@ -0,0 +1,80 @@ +/*============================================================================= + Copyright (c) 2011-2017 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_TYPE_ALGORITHM_ANY_OF_HPP +#define SPROUT_TYPE_ALGORITHM_ANY_OF_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace types { + namespace detail { + template< + typename Tuple, typename Predicate, std::size_t First, std::size_t Last, + std::size_t Pivot, + bool C1 = (Pivot == 0) + > + struct any_of_impl; + template< + typename Tuple, typename Predicate, std::size_t First, std::size_t Last, + std::size_t Pivot + > + struct any_of_impl + : public sprout::bool_constant< + sprout::types::apply::type>::type::value + > + {}; + template< + typename Tuple, typename Predicate, std::size_t First, std::size_t Last, + std::size_t Pivot + > + struct any_of_impl + : public sprout::bool_constant< + sprout::types::detail::any_of_impl< + Tuple, Predicate, First, First + Pivot, + Pivot / 2 + >::value + || sprout::types::detail::any_of_impl< + Tuple, Predicate, First + Pivot, Last, + (Last - First - Pivot) / 2 + >::value + > + {}; + template::value> + struct any_of + : public sprout::types::detail::any_of_impl + {}; + template + struct any_of + : public sprout::false_type + {}; + } // namespace detail + // + // any_of + // + template + struct any_of + : public sprout::types::detail::any_of + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using any_of_t = typename sprout::types::any_of::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES + +#if SPROUT_USE_VARIABLE_TEMPLATES + template + SPROUT_STATIC_CONSTEXPR bool any_of_v = sprout::types::any_of::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES + } // namespace types +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_ALGORITHM_ANY_OF_HPP diff --git a/sprout/type/algorithm/any_of_same.hpp b/sprout/type/algorithm/any_of_same.hpp new file mode 100644 index 00000000..444759bc --- /dev/null +++ b/sprout/type/algorithm/any_of_same.hpp @@ -0,0 +1,79 @@ +/*============================================================================= + Copyright (c) 2011-2017 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_TYPE_ALGORITHM_ANY_OF_SAME_HPP +#define SPROUT_TYPE_ALGORITHM_ANY_OF_SAME_HPP + +#include +#include +#include +#include + +namespace sprout { + namespace types { + namespace detail { + template< + typename Tuple, typename T, std::size_t First, std::size_t Last, + std::size_t Pivot, + bool C1 = (Pivot == 0) + > + struct any_of_same_impl; + template< + typename Tuple, typename T, std::size_t First, std::size_t Last, + std::size_t Pivot + > + struct any_of_same_impl + : public sprout::bool_constant< + std::is_same::type, T>::value + > + {}; + template< + typename Tuple, typename T, std::size_t First, std::size_t Last, + std::size_t Pivot + > + struct any_of_same_impl + : public sprout::bool_constant< + sprout::types::detail::any_of_same_impl< + Tuple, T, First, First + Pivot, + Pivot / 2 + >::value + || sprout::types::detail::any_of_same_impl< + Tuple, T, First + Pivot, Last, + (Last - First - Pivot) / 2 + >::value + > + {}; + template::value> + struct any_of_same + : public sprout::types::detail::any_of_same_impl + {}; + template + struct any_of_same + : public sprout::false_type + {}; + } // namespace detail + // + // any_of_same + // + template + struct any_of_same + : public sprout::types::detail::any_of_same + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using any_of_same_t = typename sprout::types::any_of_same::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES + +#if SPROUT_USE_VARIABLE_TEMPLATES + template + SPROUT_STATIC_CONSTEXPR bool any_of_same_v = sprout::types::any_of_same::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES + } // namespace types +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_ALGORITHM_ANY_OF_SAME_HPP diff --git a/sprout/type/algorithm/contains.hpp b/sprout/type/algorithm/contains.hpp index a8943923..919dd325 100644 --- a/sprout/type/algorithm/contains.hpp +++ b/sprout/type/algorithm/contains.hpp @@ -10,7 +10,7 @@ #include #include -#include +#include namespace sprout { namespace types { @@ -19,7 +19,7 @@ namespace sprout { // template struct contains - : public sprout::types::find_index::is_found + : public sprout::types::any_of_same {}; #if SPROUT_USE_TEMPLATE_ALIASES diff --git a/sprout/type/algorithm/contains_if.hpp b/sprout/type/algorithm/contains_if.hpp index af17229d..a2040357 100644 --- a/sprout/type/algorithm/contains_if.hpp +++ b/sprout/type/algorithm/contains_if.hpp @@ -10,7 +10,7 @@ #include #include -#include +#include namespace sprout { namespace types { @@ -19,7 +19,7 @@ namespace sprout { // template struct contains_if - : public sprout::types::find_index_if::is_found + : public sprout::types::any_of {}; #if SPROUT_USE_TEMPLATE_ALIASES diff --git a/sprout/type/algorithm/none_of.hpp b/sprout/type/algorithm/none_of.hpp new file mode 100644 index 00000000..2ff0fa61 --- /dev/null +++ b/sprout/type/algorithm/none_of.hpp @@ -0,0 +1,80 @@ +/*============================================================================= + Copyright (c) 2011-2017 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_TYPE_ALGORITHM_NONE_OF_HPP +#define SPROUT_TYPE_ALGORITHM_NONE_OF_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace types { + namespace detail { + template< + typename Tuple, typename Predicate, std::size_t First, std::size_t Last, + std::size_t Pivot, + bool C1 = (Pivot == 0) + > + struct none_of_impl; + template< + typename Tuple, typename Predicate, std::size_t First, std::size_t Last, + std::size_t Pivot + > + struct none_of_impl + : public sprout::bool_constant< + !sprout::types::apply::type>::type::value + > + {}; + template< + typename Tuple, typename Predicate, std::size_t First, std::size_t Last, + std::size_t Pivot + > + struct none_of_impl + : public sprout::bool_constant< + sprout::types::detail::none_of_impl< + Tuple, Predicate, First, First + Pivot, + Pivot / 2 + >::value + && sprout::types::detail::none_of_impl< + Tuple, Predicate, First + Pivot, Last, + (Last - First - Pivot) / 2 + >::value + > + {}; + template::value> + struct none_of + : public sprout::types::detail::none_of_impl + {}; + template + struct none_of + : public sprout::true_type + {}; + } // namespace detail + // + // none_of + // + template + struct none_of + : public sprout::types::detail::none_of + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using none_of_t = typename sprout::types::none_of::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES + +#if SPROUT_USE_VARIABLE_TEMPLATES + template + SPROUT_STATIC_CONSTEXPR bool none_of_v = sprout::types::none_of::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES + } // namespace types +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_ALGORITHM_NONE_OF_HPP diff --git a/sprout/type/algorithm/none_of_same.hpp b/sprout/type/algorithm/none_of_same.hpp new file mode 100644 index 00000000..f6f3373d --- /dev/null +++ b/sprout/type/algorithm/none_of_same.hpp @@ -0,0 +1,79 @@ +/*============================================================================= + Copyright (c) 2011-2017 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_TYPE_ALGORITHM_NONE_OF_SAME_HPP +#define SPROUT_TYPE_ALGORITHM_NONE_OF_SAME_HPP + +#include +#include +#include +#include + +namespace sprout { + namespace types { + namespace detail { + template< + typename Tuple, typename T, std::size_t First, std::size_t Last, + std::size_t Pivot, + bool C1 = (Pivot == 0) + > + struct none_of_same_impl; + template< + typename Tuple, typename T, std::size_t First, std::size_t Last, + std::size_t Pivot + > + struct none_of_same_impl + : public sprout::bool_constant< + !std::is_same::type, T>::value + > + {}; + template< + typename Tuple, typename T, std::size_t First, std::size_t Last, + std::size_t Pivot + > + struct none_of_same_impl + : public sprout::bool_constant< + sprout::types::detail::none_of_same_impl< + Tuple, T, First, First + Pivot, + Pivot / 2 + >::value + && sprout::types::detail::none_of_same_impl< + Tuple, T, First + Pivot, Last, + (Last - First - Pivot) / 2 + >::value + > + {}; + template::value> + struct none_of_same + : public sprout::types::detail::none_of_same_impl + {}; + template + struct none_of_same + : public sprout::true_type + {}; + } // namespace detail + // + // none_of_same + // + template + struct none_of_same + : public sprout::types::detail::none_of_same + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using none_of_same_t = typename sprout::types::none_of_same::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES + +#if SPROUT_USE_VARIABLE_TEMPLATES + template + SPROUT_STATIC_CONSTEXPR bool none_of_same_v = sprout::types::none_of_same::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES + } // namespace types +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_ALGORITHM_NONE_OF_SAME_HPP diff --git a/sprout/type/algorithm/one_of.hpp b/sprout/type/algorithm/one_of.hpp new file mode 100644 index 00000000..1d482bad --- /dev/null +++ b/sprout/type/algorithm/one_of.hpp @@ -0,0 +1,115 @@ +/*============================================================================= + Copyright (c) 2011-2017 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_TYPE_ALGORITHM_ONE_OF_HPP +#define SPROUT_TYPE_ALGORITHM_ONE_OF_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + namespace types { + namespace detail { + template< + typename Tuple, typename Predicate, std::size_t First, std::size_t Last, + std::size_t Pivot, + bool C1 = (Pivot == 0) + > + struct one_of_impl_1; + template< + typename Tuple, typename Predicate, std::size_t First, std::size_t Last, + std::size_t Pivot + > + struct one_of_impl_1 + : public sprout::bool_constant< + !sprout::types::apply::type>::type::value + > + {}; + template< + typename Tuple, typename Predicate, std::size_t First, std::size_t Last, + std::size_t Pivot + > + struct one_of_impl_1 + : public sprout::bool_constant< + sprout::types::detail::one_of_impl_1< + Tuple, Predicate, First, First + Pivot, + Pivot / 2 + >::value + && sprout::types::detail::one_of_impl_1< + Tuple, Predicate, First + Pivot, Last, + (Last - First - Pivot) / 2 + >::value + > + {}; + template< + typename Tuple, typename Predicate, std::size_t First, std::size_t Last, + std::size_t Pivot, + bool C1 = (Pivot == 0) + > + struct one_of_impl; + template< + typename Tuple, typename Predicate, std::size_t First, std::size_t Last, + std::size_t Pivot + > + struct one_of_impl + : public sprout::bool_constant< + sprout::types::apply::type>::type::value + > + {}; + template< + typename Tuple, typename Predicate, std::size_t First, std::size_t Last, + std::size_t Pivot + > + struct one_of_impl + : public sprout::bool_constant< + sprout::types::detail::one_of_impl< + Tuple, Predicate, First, First + Pivot, + Pivot / 2 + >::value + ? sprout::types::detail::one_of_impl_1< + Tuple, Predicate, First + Pivot, Last, + (Last - First - Pivot) / 2 + >::value + : sprout::types::detail::one_of_impl< + Tuple, Predicate, First + Pivot, Last, + (Last - First - Pivot) / 2 + >::value + > + {}; + template::value> + struct one_of + : public sprout::types::detail::one_of_impl + {}; + template + struct one_of + : public sprout::true_type + {}; + } // namespace detail + // + // one_of + // + template + struct one_of + : public sprout::types::detail::one_of + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using one_of_t = typename sprout::types::one_of::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES + +#if SPROUT_USE_VARIABLE_TEMPLATES + template + SPROUT_STATIC_CONSTEXPR bool one_of_v = sprout::types::one_of::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES + } // namespace types +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_ALGORITHM_ONE_OF_HPP diff --git a/sprout/type/algorithm/one_of_same.hpp b/sprout/type/algorithm/one_of_same.hpp new file mode 100644 index 00000000..1bb86b6e --- /dev/null +++ b/sprout/type/algorithm/one_of_same.hpp @@ -0,0 +1,114 @@ +/*============================================================================= + Copyright (c) 2011-2017 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_TYPE_ALGORITHM_ONE_OF_SAME_HPP +#define SPROUT_TYPE_ALGORITHM_ONE_OF_SAME_HPP + +#include +#include +#include +#include + +namespace sprout { + namespace types { + namespace detail { + template< + typename Tuple, typename T, std::size_t First, std::size_t Last, + std::size_t Pivot, + bool C1 = (Pivot == 0) + > + struct one_of_same_impl_1; + template< + typename Tuple, typename T, std::size_t First, std::size_t Last, + std::size_t Pivot + > + struct one_of_same_impl_1 + : public sprout::bool_constant< + !std::is_same::type, T>::value + > + {}; + template< + typename Tuple, typename T, std::size_t First, std::size_t Last, + std::size_t Pivot + > + struct one_of_same_impl_1 + : public sprout::bool_constant< + sprout::types::detail::one_of_same_impl_1< + Tuple, T, First, First + Pivot, + Pivot / 2 + >::value + && sprout::types::detail::one_of_same_impl_1< + Tuple, T, First + Pivot, Last, + (Last - First - Pivot) / 2 + >::value + > + {}; + template< + typename Tuple, typename T, std::size_t First, std::size_t Last, + std::size_t Pivot, + bool C1 = (Pivot == 0) + > + struct one_of_same_impl; + template< + typename Tuple, typename T, std::size_t First, std::size_t Last, + std::size_t Pivot + > + struct one_of_same_impl + : public sprout::bool_constant< + std::is_same::type, T>::value + > + {}; + template< + typename Tuple, typename T, std::size_t First, std::size_t Last, + std::size_t Pivot + > + struct one_of_same_impl + : public sprout::bool_constant< + sprout::types::detail::one_of_same_impl< + Tuple, T, First, First + Pivot, + Pivot / 2 + >::value + ? sprout::types::detail::one_of_same_impl_1< + Tuple, T, First + Pivot, Last, + (Last - First - Pivot) / 2 + >::value + : sprout::types::detail::one_of_same_impl< + Tuple, T, First + Pivot, Last, + (Last - First - Pivot) / 2 + >::value + > + {}; + template::value> + struct one_of_same + : public sprout::types::detail::one_of_same_impl + {}; + template + struct one_of_same + : public sprout::true_type + {}; + } // namespace detail + // + // one_of_same + // + template + struct one_of_same + : public sprout::types::detail::one_of_same + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using one_of_same_t = typename sprout::types::one_of_same::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES + +#if SPROUT_USE_VARIABLE_TEMPLATES + template + SPROUT_STATIC_CONSTEXPR bool one_of_same_v = sprout::types::one_of_same::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES + } // namespace types +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_ALGORITHM_ONE_OF_SAME_HPP diff --git a/sprout/type_traits/has_unique_object_representations.hpp b/sprout/type_traits/has_unique_object_representations.hpp new file mode 100644 index 00000000..1f84e828 --- /dev/null +++ b/sprout/type_traits/has_unique_object_representations.hpp @@ -0,0 +1,41 @@ +/*============================================================================= + Copyright (c) 2011-2017 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_TYPE_TRAITS_HAS_UNIQUE_OBJECT_REPRESENTATIONS_HPP +#define SPROUT_TYPE_TRAITS_HAS_UNIQUE_OBJECT_REPRESENTATIONS_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + // + // has_unique_object_representations + // +#if SPROUT_CLANG_HAS_FUTURE(has_unique_object_representations) || SPROUT_GCC_OR_LATER(7, 0, 0) + template + struct has_unique_object_representations + : public sprout::bool_constant< + __has_unique_object_representations(typename sprout::remove_cv::type>::type) + > + {}; +#else // #if SPROUT_CLANG_HAS_FUTURE(has_unique_object_representations) || SPROUT_GCC_OR_LATER(7, 0, 0) + template + struct has_unique_object_representations + : public sprout::false_type + {}; +#endif // #if SPROUT_CLANG_HAS_FUTURE(has_unique_object_representations) || SPROUT_GCC_OR_LATER(7, 0, 0) + +#if SPROUT_USE_VARIABLE_TEMPLATES + template + SPROUT_STATIC_CONSTEXPR bool has_unique_object_representations_v = sprout::has_unique_object_representations::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_HAS_UNIQUE_OBJECT_REPRESENTATIONS_HPP diff --git a/sprout/type_traits/invoke_result.hpp b/sprout/type_traits/invoke_result.hpp new file mode 100644 index 00000000..14310fcf --- /dev/null +++ b/sprout/type_traits/invoke_result.hpp @@ -0,0 +1,29 @@ +/*============================================================================= + Copyright (c) 2011-2017 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_TYPE_TRAITS_INVOKE_RESULT_HPP +#define SPROUT_TYPE_TRAITS_INVOKE_RESULT_HPP + +#include +#include + +namespace sprout { + // + // invoke_result + // + template + struct invoke_result + : public sprout::detail::invoke_result + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using invoke_result_t = typename sprout::invoke_result::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_INVOKE_RESULT_HPP diff --git a/sprout/type_traits/is_aggregate.hpp b/sprout/type_traits/is_aggregate.hpp new file mode 100644 index 00000000..0c85f6e6 --- /dev/null +++ b/sprout/type_traits/is_aggregate.hpp @@ -0,0 +1,41 @@ +/*============================================================================= + Copyright (c) 2011-2017 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_TYPE_TRAITS_IS_AGGREGATE_HPP +#define SPROUT_TYPE_TRAITS_IS_AGGREGATE_HPP + +#include +#include +#include +#include +#include + +namespace sprout { + // + // is_aggregate + // +#if SPROUT_CLANG_HAS_FUTURE(is_aggregate) || SPROUT_GCC_OR_LATER(7, 0, 0) + template + struct is_aggregate + : public sprout::bool_constant< + __is_aggregate(typename sprout::remove_cv::type>::type) + > + {}; +#else // #if SPROUT_CLANG_HAS_FUTURE(is_aggregate) || SPROUT_GCC_OR_LATER(7, 0, 0) + template + struct is_aggregate + : public sprout::false_type + {}; +#endif // #if SPROUT_CLANG_HAS_FUTURE(is_aggregate) || SPROUT_GCC_OR_LATER(7, 0, 0) + +#if SPROUT_USE_VARIABLE_TEMPLATES + template + SPROUT_STATIC_CONSTEXPR bool is_aggregate_v = sprout::is_aggregate::value; +#endif // #if SPROUT_USE_VARIABLE_TEMPLATES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_IS_AGGREGATE_HPP diff --git a/sprout/type_traits/property.hpp b/sprout/type_traits/property.hpp index fd0d0f5a..cccd2f8f 100644 --- a/sprout/type_traits/property.hpp +++ b/sprout/type_traits/property.hpp @@ -17,10 +17,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include diff --git a/sprout/type_traits/result_of.hpp b/sprout/type_traits/result_of.hpp index 42adab6c..41bf7ab4 100644 --- a/sprout/type_traits/result_of.hpp +++ b/sprout/type_traits/result_of.hpp @@ -8,215 +8,55 @@ #ifndef SPROUT_TYPE_TRAITS_RESULT_OF_HPP #define SPROUT_TYPE_TRAITS_RESULT_OF_HPP -#if defined(_MSC_VER) && (_MSC_VER <= 1900) -# include -#endif #include -#include #include #include -#include -#include namespace sprout { -#if defined(_MSC_VER) && (_MSC_VER <= 1900) - // - // result_of - // - using std::result_of; -#else - // - // result_of - // namespace detail { - struct result_of_memfun_ref_helper { - public: - template - static sprout::identity().*std::declval())(std::declval()...))> test(sprout::types::type_tuple); - template - static sprout::detail::nil_base test(...); - }; -#if defined(_MSC_VER) && (_MSC_VER > 1900) - template< - typename MemPtr, typename Arg, typename Args, - typename Base_ = typename sprout::identity(Args()))>::type - > - struct result_of_memfun_ref_impl - : public Base_ - {}; - template - struct result_of_memfun_ref - : public sprout::detail::result_of_memfun_ref_impl > - {}; -#else - template - struct result_of_memfun_ref - : public sprout::identity(sprout::types::type_tuple()))>::type - {}; -#endif + template + inline SPROUT_CONSTEXPR decltype(std::declval()(std::declval()...)) + invoke(F&&, Args&&...); - struct result_of_memfun_deref_helper { - public: - template - static sprout::identity()).*std::declval())(std::declval()...))> test(sprout::types::type_tuple); - template - static sprout::detail::nil_base test(...); - }; -#if defined(_MSC_VER) && (_MSC_VER > 1900) - template< - typename MemPtr, typename Arg, typename Args, - typename Base_ = typename sprout::identity(Args()))>::type - > - struct result_of_memfun_deref_impl - : public Base_ - {}; - template - struct result_of_memfun_deref - : public sprout::detail::result_of_memfun_deref_impl > - {}; -#else - template - struct result_of_memfun_deref - : public sprout::identity(sprout::types::type_tuple()))>::type - {}; -#endif + template + inline SPROUT_CONSTEXPR decltype(std::declval().*(std::declval())) + invoke(T Base::*, Derived&&); - struct result_of_memobj_ref_helper { - public: - template - static sprout::identity().*std::declval())> test(int); - template - static sprout::detail::nil_base test(...); - }; -#if defined(_MSC_VER) && (_MSC_VER > 1900) - template< - typename MemPtr, typename Arg, - typename Base_ = typename sprout::identity(0))>::type - > - struct result_of_memobj_ref - : public Base_ - {}; -#else - template - struct result_of_memobj_ref - : public sprout::identity(0))>::type - {}; -#endif + template + inline SPROUT_CONSTEXPR decltype((*std::declval()).*(std::declval())) + invoke(PMD&&, Pointer&&); - struct result_of_memobj_deref_helper { - public: - template - static sprout::identity()).*std::declval())> test(int); - template - static sprout::detail::nil_base test(...); - }; -#if defined(_MSC_VER) && (_MSC_VER > 1900) - template< - typename MemPtr, typename Arg, - typename Base_ = typename sprout::identity(0))>::type - > - struct result_of_memobj_deref - : public Base_ - {}; -#else - template - struct result_of_memobj_deref - : public sprout::identity(0))>::type - {}; -#endif + template + inline SPROUT_CONSTEXPR decltype((std::declval().*(std::declval()))(std::declval()...)) + invoke(T Base::*, Derived&&, Args&&...); - template - struct result_of_memobj_impl; - template - struct result_of_memobj_impl { - public: - typedef typename std::remove_cv::type>::type argval_type; - typedef R Class::* mem_ptr_type; - typedef typename std::conditional< - std::is_same::value || std::is_base_of::value, - sprout::detail::result_of_memobj_ref, - sprout::detail::result_of_memobj_deref - >::type type; - }; - template - struct result_of_memobj - : public sprout::detail::result_of_memobj_impl::type - {}; + template + inline SPROUT_CONSTEXPR decltype(((*std::declval()).*(std::declval()))(std::declval()...)) + invoke(PMF&& pmf, Pointer&& ptr, Args&&... args); + } // namespace detail - template - struct result_of_memfun_impl; - template - struct result_of_memfun_impl { - public: - typedef typename std::remove_cv::type>::type argval_type; - typedef R Class::* mem_ptr_type; - typedef typename std::conditional< - std::is_same::value || std::is_base_of::value, - result_of_memfun_ref, - result_of_memfun_deref - >::type type; - }; - template - struct result_of_memfun - : public sprout::detail::result_of_memfun_impl::type + namespace detail { + template + struct invoke_result {}; + template + struct invoke_result(), std::declval()...))), F, Args...> + : public sprout::identity(), std::declval()...))> {}; + } // namespace detail - struct result_of_other_impl { - public: - template - static sprout::identity()(std::declval()...))> test(int); - template - static sprout::detail::nil_base test(...); - }; -#if defined(_MSC_VER) - template - struct result_of_other_base { - public: - typedef typename sprout::identity(0))>::type type; - }; - template - struct result_of_other - : public sprout::detail::result_of_other_base::type - {}; -#else - template - struct result_of_other - : public sprout::identity(0))>::type - {}; -#endif - - template - struct result_of_impl - : public sprout::identity::type - {}; - template - struct result_of_impl - : public sprout::detail::result_of_memobj::type, Arg> - {}; - template - struct result_of_impl - : public sprout::detail::result_of_memfun::type, Arg, Args...> - {}; - template - struct result_of_impl - : public sprout::detail::result_of_other - {}; - } //namespace detail - template + // + // result_of + // + template struct result_of; - template - struct result_of - : public sprout::detail::result_of_impl< - std::is_member_object_pointer::type>::value, - std::is_member_function_pointer::type>::value, - Functor, Args... - > + template + struct result_of + : public sprout::detail::invoke_result {}; -#endif #if SPROUT_USE_TEMPLATE_ALIASES - template - using result_of_t = typename sprout::result_of::type; + template + using result_of_t = typename sprout::result_of::type; #endif // #if SPROUT_USE_TEMPLATE_ALIASES } // namespace sprout diff --git a/sprout/type_traits/transformation.hpp b/sprout/type_traits/transformation.hpp index 96248dec..258d39f9 100644 --- a/sprout/type_traits/transformation.hpp +++ b/sprout/type_traits/transformation.hpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include diff --git a/tools/darkroom/darkcult.sh b/tools/darkroom/darkcult.sh index 1511963a..d6dd6796 100755 --- a/tools/darkroom/darkcult.sh +++ b/tools/darkroom/darkcult.sh @@ -34,6 +34,11 @@ use_help=0 darkcult_cpp=$(cd $(dirname $0); pwd)/darkcult.cpp darkcult_py=$(cd $(dirname $0); pwd)/darkcult.py +get_used_mem() { + local mem_info=(`free -m | sed -n "/^Mem:/s/^Mem:[ \t]*//p"`) + echo -n "${mem_info[1]}" +} + args=`getopt -o s:S:o:C:w:h:W:H:l:t:r:b:O:D:I:P:fc -l source:,stagedir:,output:,compiler:,width:,height:,tile-width:,tile-height:,left:,top:,right:,bottom:,option:,define:,include:,max-procs:,force,continuable,runtime,version,help -- "$@"` if [ "$?" -ne 0 ]; then echo >&2 "error: options parse error. See 'darkcult.sh --help'" @@ -142,7 +147,7 @@ if [ ${use_version} -ne 0 ]; then sprout_version_yyyymmdd=`sed -n "s/[ \t]*#[ \t]*define[ \t]\+SPROUT_VERSION_YYYYMMDD[ \t]\+//p" ${version_hpp_path}` sprout_copyright=`sed -n "/\/\*=/,/=\*\//s/^[ \t]\+/ /p" ${version_hpp_path}` echo "version:" - echo " Sprout version (YYYYMMDD) = ${sprout_version_yyyymmdd}" + echo " Sprout version(YYYYMMDD) = ${sprout_version_yyyymmdd}" echo "copyright:" echo "${sprout_copyright}" exit 0 @@ -202,6 +207,7 @@ for ((y=0; y&2 " error: compile(${y}/${x}) failed." exit 1 fi + done echo "" @@ -252,6 +259,7 @@ else echo "" if [ ${result} -eq 2 ]; then echo " compile terminated." + is_terminated=1 exit 0 elif [ ${result} -ne 0 ]; then echo >&2 " error: compile failed." @@ -262,13 +270,15 @@ fi let elapsed=${SECONDS}-${start} echo " elapsed(total) = ${elapsed}s" -for ((y=0; y /dev/null - pnmcat -lr $(ls *.ppm | sort -n) > ../${y}.ppm +if [ ${is_uncompleted} -eq 0 ]; then + for ((y=0; y /dev/null + pnmcat -lr $(ls *.ppm | sort -n) > ../${y}.ppm + popd > /dev/null + done + pushd ${stagedir} > /dev/null + pnmcat -tb $(ls *.ppm | sort -n) > ${output} popd > /dev/null -done -pushd ${stagedir} > /dev/null -pnmcat -tb $(ls *.ppm | sort -n) > ${output} -popd > /dev/null +fi echo "finished." diff --git a/tools/testspr/test.sh b/tools/testspr/test.sh index c3da0261..6693cdd0 100755 --- a/tools/testspr/test.sh +++ b/tools/testspr/test.sh @@ -177,7 +177,7 @@ if [ ${use_version} -ne 0 ]; then sprout_version_yyyymmdd=`sed -n "s/[ \t]*#[ \t]*define[ \t]\+SPROUT_VERSION_YYYYMMDD[ \t]\+//p" ${version_hpp_path}` sprout_copyright=`sed -n "/\/\*=/,/=\*\//s/^[ \t]\+/ /p" ${version_hpp_path}` echo "version:" - echo " Sprout version (YYYYMMDD) = ${sprout_version_yyyymmdd}" + echo " Sprout version(YYYYMMDD) = ${sprout_version_yyyymmdd}" echo "copyright:" echo "${sprout_copyright}" exit 0