From 2e8b85e90c7cfd68cd9291e0f228255c1b8688c4 Mon Sep 17 00:00:00 2001 From: bolero-MURAKAMI Date: Wed, 27 Mar 2013 02:02:16 +0900 Subject: [PATCH] fix tuple construction, darkroom rgb & vector3d construction --- libs/tuple/test/tuple.cpp | 34 +++++++++----- sprout/algorithm/string/join.hpp | 18 ++++---- sprout/container/internal.hpp | 11 ++--- sprout/darkroom/colors/rgb.hpp | 19 +++++++- sprout/darkroom/coords/vector.hpp | 8 +++- sprout/darkroom/intersects/intersection.hpp | 4 +- sprout/darkroom/lights/ambient_light.hpp | 2 +- sprout/darkroom/lights/parallel_light.hpp | 4 +- sprout/darkroom/lights/point_light.hpp | 4 +- sprout/darkroom/materials/material.hpp | 2 +- sprout/darkroom/objects/aa_plane.hpp | 2 +- sprout/darkroom/objects/polygon/triangle.hpp | 2 +- sprout/darkroom/objects/sphere.hpp | 2 +- sprout/darkroom/pixels/generate.hpp | 2 +- sprout/darkroom/rays/ray.hpp | 2 +- sprout/darkroom/renderers/infinity.hpp | 2 +- sprout/darkroom/textures/texture.hpp | 2 +- sprout/darkroom/tracers/raytracer.hpp | 2 +- sprout/operation/fixed/append.hpp | 9 ++-- sprout/operation/fixed/erase.hpp | 10 ++--- sprout/operation/fixed/erase_n.hpp | 10 ++--- sprout/operation/fixed/insert.hpp | 9 ++-- sprout/operation/fixed/insert_n.hpp | 9 ++-- sprout/operation/fixed/resize.hpp | 9 ++-- .../adaptor/detail/jointed_range_default.hpp | 29 +++++------- sprout/tuple/traits.hpp | 9 ++-- sprout/tuple/tuple.hpp | 1 + sprout/tuple/tuple/flexibly_construct.hpp | 20 +++++++++ sprout/tuple/tuple/get.hpp | 27 +++++------- sprout/tuple/tuple/make_tuple.hpp | 9 ++-- sprout/tuple/tuple/tuple.hpp | 44 +++++++++++++------ sprout/type/iterator/advance.hpp | 7 ++- sprout/type/iterator/deref.hpp | 7 ++- sprout/type_traits.hpp | 1 + .../type_traits/is_convert_constructible.hpp | 32 ++++++++++++++ sprout/utility/pack.hpp | 7 ++- sprout/variant/variant.hpp | 25 +++++------ sprout/weed/expr/make_terminal.hpp | 5 +-- sprout/weed/expr/make_terminal_or_expr.hpp | 5 +-- sprout/weed/operator/address_of.hpp | 3 +- sprout/weed/operator/bitwise_or.hpp | 5 +-- sprout/weed/operator/dereference.hpp | 3 +- sprout/weed/operator/logical_not.hpp | 3 +- sprout/weed/operator/mem_ptr.hpp | 3 +- sprout/weed/operator/minus.hpp | 5 +-- sprout/weed/operator/modulus.hpp | 5 +-- sprout/weed/operator/negate.hpp | 3 +- sprout/weed/operator/shift_left.hpp | 5 +-- sprout/weed/operator/unary_plus.hpp | 3 +- sprout/weed/parser/lit.hpp | 3 +- sprout/weed/traits/expr/expr_of.hpp | 3 +- sprout/weed/traits/expr/terminal_of.hpp | 6 +-- .../weed/traits/expr/terminal_or_expr_of.hpp | 2 +- 53 files changed, 262 insertions(+), 196 deletions(-) create mode 100644 sprout/tuple/tuple/flexibly_construct.hpp create mode 100644 sprout/type_traits/is_convert_constructible.hpp diff --git a/libs/tuple/test/tuple.cpp b/libs/tuple/test/tuple.cpp index 49b5feee..82c414b2 100644 --- a/libs/tuple/test/tuple.cpp +++ b/libs/tuple/test/tuple.cpp @@ -29,34 +29,44 @@ namespace testspr { TESTSPR_BOTH_ASSERT(sprout::tuples::get<1>(tup3) == 1.0); } - { - SPROUT_STATIC_CONSTEXPR auto tup3 = sprout::tuples::tuple(1l); - TESTSPR_BOTH_ASSERT(sprout::tuples::get<0>(tup3) == 1); - TESTSPR_BOTH_ASSERT(sprout::tuples::get<1>(tup3) == 0.0); - } { SPROUT_STATIC_CONSTEXPR auto tup3 = sprout::tuples::tuple(1l, 1.0f); TESTSPR_BOTH_ASSERT(sprout::tuples::get<0>(tup3) == 1); TESTSPR_BOTH_ASSERT(sprout::tuples::get<1>(tup3) == 1.0); } { - SPROUT_STATIC_CONSTEXPR auto tup3 = sprout::tuples::tuple(1l, 1.0f, '-'); + SPROUT_STATIC_CONSTEXPR auto tup3 = sprout::tuples::tuple(sprout::tuples::flexibly_construct, 1l); + TESTSPR_BOTH_ASSERT(sprout::tuples::get<0>(tup3) == 1); + TESTSPR_BOTH_ASSERT(sprout::tuples::get<1>(tup3) == 0.0); + } + { + SPROUT_STATIC_CONSTEXPR auto tup3 = sprout::tuples::tuple(sprout::tuples::flexibly_construct, 1l, 1.0f); + TESTSPR_BOTH_ASSERT(sprout::tuples::get<0>(tup3) == 1); + TESTSPR_BOTH_ASSERT(sprout::tuples::get<1>(tup3) == 1.0); + } + { + SPROUT_STATIC_CONSTEXPR auto tup3 = sprout::tuples::tuple(sprout::tuples::flexibly_construct, 1l, 1.0f, '-'); TESTSPR_BOTH_ASSERT(sprout::tuples::get<0>(tup3) == 1); TESTSPR_BOTH_ASSERT(sprout::tuples::get<1>(tup3) == 1.0); } - { - SPROUT_STATIC_CONSTEXPR auto tup3 = sprout::tuples::tuple(sprout::tuples::tuple(1l)); - TESTSPR_BOTH_ASSERT(sprout::tuples::get<0>(tup3) == 1); - TESTSPR_BOTH_ASSERT(sprout::tuples::get<1>(tup3) == 0.0); - } { SPROUT_STATIC_CONSTEXPR auto tup3 = sprout::tuples::tuple(sprout::tuples::tuple(1l, 1.0f)); TESTSPR_BOTH_ASSERT(sprout::tuples::get<0>(tup3) == 1); TESTSPR_BOTH_ASSERT(sprout::tuples::get<1>(tup3) == 1.0); } { - SPROUT_STATIC_CONSTEXPR auto tup3 = sprout::tuples::tuple(sprout::tuples::tuple(1l, 1.0f, '-')); + SPROUT_STATIC_CONSTEXPR auto tup3 = sprout::tuples::tuple(sprout::tuples::flexibly_construct, sprout::tuples::tuple(1l)); + TESTSPR_BOTH_ASSERT(sprout::tuples::get<0>(tup3) == 1); + TESTSPR_BOTH_ASSERT(sprout::tuples::get<1>(tup3) == 0.0); + } + { + SPROUT_STATIC_CONSTEXPR auto tup3 = sprout::tuples::tuple(sprout::tuples::flexibly_construct, sprout::tuples::tuple(1l, 1.0f)); + TESTSPR_BOTH_ASSERT(sprout::tuples::get<0>(tup3) == 1); + TESTSPR_BOTH_ASSERT(sprout::tuples::get<1>(tup3) == 1.0); + } + { + SPROUT_STATIC_CONSTEXPR auto tup3 = sprout::tuples::tuple(sprout::tuples::flexibly_construct, sprout::tuples::tuple(1l, 1.0f, '-')); TESTSPR_BOTH_ASSERT(sprout::tuples::get<0>(tup3) == 1); TESTSPR_BOTH_ASSERT(sprout::tuples::get<1>(tup3) == 1.0); } diff --git a/sprout/algorithm/string/join.hpp b/sprout/algorithm/string/join.hpp index 370a66fa..c41fb5d3 100644 --- a/sprout/algorithm/string/join.hpp +++ b/sprout/algorithm/string/join.hpp @@ -62,9 +62,8 @@ namespace sprout { // join // template - struct join { - public: - typedef typename sprout::container_transform_traits< + struct join + : public sprout::container_transform_traits< typename sprout::container_traits::value_type >::template rebind_size< sprout::container_traits< @@ -78,20 +77,19 @@ namespace sprout { * sprout::container_traits::static_size - sprout::algorithm::detail::string_size::value : 0 - >::type type; - }; + > + {}; template - struct join { - public: - typedef typename sprout::container_transform_traits< + struct join + : public sprout::container_transform_traits< typename sprout::container_traits::value_type >::template rebind_size< sprout::container_traits< typename sprout::container_traits::value_type >::static_size * sprout::container_traits::static_size - >::type type; - }; + > + {}; } // namespace result_of namespace detail { diff --git a/sprout/container/internal.hpp b/sprout/container/internal.hpp index d2594b2e..f0294f6a 100644 --- a/sprout/container/internal.hpp +++ b/sprout/container/internal.hpp @@ -11,14 +11,11 @@ namespace sprout { // internal // template - struct internal { - public: - typedef typename sprout::sub_container_traits< + struct internal + : public sprout::sub_container_traits< typename std::remove_reference::type - >::template internal< - Container - >::type type; - }; + >::template internal + {}; } // namespace containers } // namespace sprout diff --git a/sprout/darkroom/colors/rgb.hpp b/sprout/darkroom/colors/rgb.hpp index 989d9cca..80f41c51 100644 --- a/sprout/darkroom/colors/rgb.hpp +++ b/sprout/darkroom/colors/rgb.hpp @@ -52,11 +52,26 @@ namespace sprout { } // + // rgb_t // rgb + // + typedef sprout::tuples::tuple rgb_t; + + inline SPROUT_CONSTEXPR sprout::darkroom::colors::rgb_t + rgb(std::uint8_t r = 0, std::uint8_t g = 0, std::uint8_t b = 0) { + return sprout::darkroom::colors::rgb_t(r, g, b); + } + + // + // rgb_f_t // rgb_f // - typedef sprout::tuples::tuple rgb; - typedef sprout::tuples::tuple rgb_f; + typedef sprout::tuples::tuple rgb_f_t; + + inline SPROUT_CONSTEXPR sprout::darkroom::colors::rgb_f_t + rgb_f(double r = 0, double g = 0, double b = 0) { + return sprout::darkroom::colors::rgb_f_t(r, g, b); + } // // mul diff --git a/sprout/darkroom/coords/vector.hpp b/sprout/darkroom/coords/vector.hpp index ccd55f01..7b4b1251 100644 --- a/sprout/darkroom/coords/vector.hpp +++ b/sprout/darkroom/coords/vector.hpp @@ -42,9 +42,15 @@ namespace sprout { } // + // vector3d_t // vector3d // - typedef sprout::tuples::tuple vector3d; + typedef sprout::tuples::tuple vector3d_t; + + inline SPROUT_CONSTEXPR sprout::darkroom::coords::vector3d_t + vector3d(double x = 0, double y = 0, double z = 0) { + return sprout::darkroom::coords::vector3d_t(x, y, z); + } // // length_sq diff --git a/sprout/darkroom/intersects/intersection.hpp b/sprout/darkroom/intersects/intersection.hpp index 66087f2e..71b0b00e 100644 --- a/sprout/darkroom/intersects/intersection.hpp +++ b/sprout/darkroom/intersects/intersection.hpp @@ -74,8 +74,8 @@ namespace sprout { typedef sprout::tuples::tuple< bool, double, - sprout::darkroom::coords::vector3d, - sprout::darkroom::coords::vector3d, + sprout::darkroom::coords::vector3d_t, + sprout::darkroom::coords::vector3d_t, sprout::darkroom::materials::material > intersection; } // namespace intersects diff --git a/sprout/darkroom/lights/ambient_light.hpp b/sprout/darkroom/lights/ambient_light.hpp index d0722db6..3d4472ab 100644 --- a/sprout/darkroom/lights/ambient_light.hpp +++ b/sprout/darkroom/lights/ambient_light.hpp @@ -15,7 +15,7 @@ namespace sprout { // // basic_ambient_light // - template + template class basic_ambient_light { public: typedef Color color_type; diff --git a/sprout/darkroom/lights/parallel_light.hpp b/sprout/darkroom/lights/parallel_light.hpp index db3ff5eb..04b5145d 100644 --- a/sprout/darkroom/lights/parallel_light.hpp +++ b/sprout/darkroom/lights/parallel_light.hpp @@ -19,8 +19,8 @@ namespace sprout { // basic_parallel_light // template< - typename Position = sprout::darkroom::coords::vector3d, - typename Color = sprout::darkroom::colors::rgb_f + typename Position = sprout::darkroom::coords::vector3d_t, + typename Color = sprout::darkroom::colors::rgb_f_t > class basic_parallel_light { public: diff --git a/sprout/darkroom/lights/point_light.hpp b/sprout/darkroom/lights/point_light.hpp index 551c9364..6b6b1279 100644 --- a/sprout/darkroom/lights/point_light.hpp +++ b/sprout/darkroom/lights/point_light.hpp @@ -19,8 +19,8 @@ namespace sprout { // basic_point_light // template< - typename Position = sprout::darkroom::coords::vector3d, - typename Color = sprout::darkroom::colors::rgb_f + typename Position = sprout::darkroom::coords::vector3d_t, + typename Color = sprout::darkroom::colors::rgb_f_t > class basic_point_light { public: diff --git a/sprout/darkroom/materials/material.hpp b/sprout/darkroom/materials/material.hpp index fc3f0b14..3534bdab 100644 --- a/sprout/darkroom/materials/material.hpp +++ b/sprout/darkroom/materials/material.hpp @@ -81,7 +81,7 @@ namespace sprout { // // material // - typedef sprout::tuples::tuple material; + typedef sprout::tuples::tuple material; } // namespace materials } // namespace darkroom } // namespace sprout diff --git a/sprout/darkroom/objects/aa_plane.hpp b/sprout/darkroom/objects/aa_plane.hpp index d2d7dbb5..2d615fd5 100644 --- a/sprout/darkroom/objects/aa_plane.hpp +++ b/sprout/darkroom/objects/aa_plane.hpp @@ -27,7 +27,7 @@ namespace sprout { // // basic_aa_plane // - template + template class basic_aa_plane { public: typedef Material material_type; diff --git a/sprout/darkroom/objects/polygon/triangle.hpp b/sprout/darkroom/objects/polygon/triangle.hpp index dc6a32ca..2f6835cb 100644 --- a/sprout/darkroom/objects/polygon/triangle.hpp +++ b/sprout/darkroom/objects/polygon/triangle.hpp @@ -17,7 +17,7 @@ namespace sprout { // // basic_triangle // - template + template class basic_triangle { public: typedef Material material_type; diff --git a/sprout/darkroom/objects/sphere.hpp b/sprout/darkroom/objects/sphere.hpp index c1c38d6b..049702f2 100644 --- a/sprout/darkroom/objects/sphere.hpp +++ b/sprout/darkroom/objects/sphere.hpp @@ -20,7 +20,7 @@ namespace sprout { // // basic_sphere // - template + template class basic_sphere { public: typedef Material material_type; diff --git a/sprout/darkroom/pixels/generate.hpp b/sprout/darkroom/pixels/generate.hpp index a191770b..f6ebe141 100644 --- a/sprout/darkroom/pixels/generate.hpp +++ b/sprout/darkroom/pixels/generate.hpp @@ -125,7 +125,7 @@ namespace sprout { // // color_pixels // - template + template struct color_pixels { public: typedef sprout::array, Height> type; diff --git a/sprout/darkroom/rays/ray.hpp b/sprout/darkroom/rays/ray.hpp index a48c803a..937acbac 100644 --- a/sprout/darkroom/rays/ray.hpp +++ b/sprout/darkroom/rays/ray.hpp @@ -43,7 +43,7 @@ namespace sprout { // // ray // - typedef sprout::tuples::tuple ray; + typedef sprout::tuples::tuple ray; // // point_of_intersection diff --git a/sprout/darkroom/renderers/infinity.hpp b/sprout/darkroom/renderers/infinity.hpp index 4ae087e6..07f82400 100644 --- a/sprout/darkroom/renderers/infinity.hpp +++ b/sprout/darkroom/renderers/infinity.hpp @@ -44,7 +44,7 @@ namespace sprout { // // uniform_color // - template + template class uniform_color { public: typedef Color color_type; diff --git a/sprout/darkroom/textures/texture.hpp b/sprout/darkroom/textures/texture.hpp index 240d094c..390c8539 100644 --- a/sprout/darkroom/textures/texture.hpp +++ b/sprout/darkroom/textures/texture.hpp @@ -47,7 +47,7 @@ namespace sprout { // // image_type // - template + template struct image_type { public: typedef Color color_type; diff --git a/sprout/darkroom/tracers/raytracer.hpp b/sprout/darkroom/tracers/raytracer.hpp index 5afafe80..09e2daa5 100644 --- a/sprout/darkroom/tracers/raytracer.hpp +++ b/sprout/darkroom/tracers/raytracer.hpp @@ -11,7 +11,7 @@ namespace sprout { // // raytracer // - template + template class raytracer { public: typedef Color color_type; diff --git a/sprout/operation/fixed/append.hpp b/sprout/operation/fixed/append.hpp index 8bf313db..d49fc84a 100644 --- a/sprout/operation/fixed/append.hpp +++ b/sprout/operation/fixed/append.hpp @@ -14,14 +14,13 @@ namespace sprout { // append // template - struct append { - public: - typedef typename sprout::container_transform_traits< + struct append + : public sprout::container_transform_traits< Container >::template rebind_size< sprout::container_traits::static_size + sprout::container_traits::static_size - >::type type; - }; + > + {}; } // namespace result_of namespace detail { diff --git a/sprout/operation/fixed/erase.hpp b/sprout/operation/fixed/erase.hpp index cf2509cb..e07fb8c2 100644 --- a/sprout/operation/fixed/erase.hpp +++ b/sprout/operation/fixed/erase.hpp @@ -14,14 +14,14 @@ namespace sprout { // erase // template - struct erase { - static_assert(sprout::container_traits::static_size >= 1, "static_size >= 1"); - public: - typedef typename sprout::container_transform_traits< + struct erase + : public sprout::container_transform_traits< Container >::template rebind_size< sprout::container_traits::static_size - 1 - >::type type; + > + { + static_assert(sprout::container_traits::static_size >= 1, "static_size >= 1"); }; } // namespace result_of diff --git a/sprout/operation/fixed/erase_n.hpp b/sprout/operation/fixed/erase_n.hpp index 7125f146..3ea50e59 100644 --- a/sprout/operation/fixed/erase_n.hpp +++ b/sprout/operation/fixed/erase_n.hpp @@ -15,14 +15,14 @@ namespace sprout { // erase_n // template - struct erase_n { - static_assert(sprout::container_traits::static_size >= N, "static_size >= N"); - public: - typedef typename sprout::container_transform_traits< + struct erase_n + : public sprout::container_transform_traits< Container >::template rebind_size< sprout::container_traits::static_size - N - >::type type; + > + { + static_assert(sprout::container_traits::static_size >= N, "static_size >= N"); }; } // namespace result_of diff --git a/sprout/operation/fixed/insert.hpp b/sprout/operation/fixed/insert.hpp index 71e82134..5bf9f851 100644 --- a/sprout/operation/fixed/insert.hpp +++ b/sprout/operation/fixed/insert.hpp @@ -16,14 +16,13 @@ namespace sprout { // insert // template - struct insert { - public: - typedef typename sprout::container_transform_traits< + struct insert + : public sprout::container_transform_traits< Container >::template rebind_size< sprout::container_traits::static_size + 1 + sizeof...(Values) - >::type type; - }; + > + {}; } // namespace result_of namespace detail { diff --git a/sprout/operation/fixed/insert_n.hpp b/sprout/operation/fixed/insert_n.hpp index 3abf7c05..2115e835 100644 --- a/sprout/operation/fixed/insert_n.hpp +++ b/sprout/operation/fixed/insert_n.hpp @@ -18,14 +18,13 @@ namespace sprout { // insert_n // template - struct insert_n { - public: - typedef typename sprout::container_transform_traits< + struct insert_n + : public sprout::container_transform_traits< Container >::template rebind_size< sprout::container_traits::static_size + (1 + sizeof...(Values)) * N - >::type type; - }; + > + {}; } // namespace result_of namespace detail { diff --git a/sprout/operation/fixed/resize.hpp b/sprout/operation/fixed/resize.hpp index ab069419..c5ae5bbd 100644 --- a/sprout/operation/fixed/resize.hpp +++ b/sprout/operation/fixed/resize.hpp @@ -15,14 +15,13 @@ namespace sprout { // resize // template - struct resize { - public: - typedef typename sprout::container_transform_traits< + struct resize + : public sprout::container_transform_traits< Container >::template rebind_size< N - >::type type; - }; + > + {}; } // namespace result_of namespace detail { diff --git a/sprout/range/adaptor/detail/jointed_range_default.hpp b/sprout/range/adaptor/detail/jointed_range_default.hpp index 319dfb35..696909f5 100644 --- a/sprout/range/adaptor/detail/jointed_range_default.hpp +++ b/sprout/range/adaptor/detail/jointed_range_default.hpp @@ -132,40 +132,35 @@ namespace sprout { }; template - class jointed_range_copied_type; - + struct jointed_range_copied_type; template - class jointed_range_copied_type< + struct jointed_range_copied_type< LRange, RRange, typename std::enable_if< sprout::containers::is_rebindable_size::value >::type - > { - public: - typedef typename sprout::container_construct_traits< + > + : public sprout::container_construct_traits< typename sprout::containers::weak_rebind_size< typename sprout::container_construct_traits::copied_type, sprout::adaptors::detail::jointed_range_size::static_size >::type - >::type copied_type; - }; - + > + {}; template - class jointed_range_copied_type< + struct jointed_range_copied_type< LRange, RRange, typename std::enable_if< !sprout::containers::is_rebindable_size::value && sprout::containers::is_rebindable_size::value >::type - > { - public: - typedef typename sprout::containers::weak_rebind_size< + > + : public sprout::containers::weak_rebind_size< typename sprout::container_construct_traits::copied_type, sprout::adaptors::detail::jointed_range_size::static_size - >::type type; - }; - + > + {}; template - class jointed_range_copied_type< + struct jointed_range_copied_type< LRange, RRange, typename std::enable_if< !sprout::containers::is_rebindable_size::value && !sprout::containers::is_rebindable_size::value diff --git a/sprout/tuple/traits.hpp b/sprout/tuple/traits.hpp index 7861e1d4..9488c6ac 100644 --- a/sprout/tuple/traits.hpp +++ b/sprout/tuple/traits.hpp @@ -46,14 +46,13 @@ namespace sprout { template struct default_copied; template - struct default_copied > { - public: - typedef typename sprout::tuples::rebind_types::template apply< + struct default_copied > + : public sprout::tuples::rebind_types::template apply< typename std::decay< typename sprout::tuples::tuple_element::type >::type... - >::type type; - }; + > + {}; template SPROUT_CONSTEXPR typename sprout::tuples::tuple_construct_traits::copied_type diff --git a/sprout/tuple/tuple.hpp b/sprout/tuple/tuple.hpp index da2b0ec5..e59f8fa2 100644 --- a/sprout/tuple/tuple.hpp +++ b/sprout/tuple/tuple.hpp @@ -10,5 +10,6 @@ #include #include #include +#include #endif // #ifndef SPROUT_TUPLE_TUPLE_HPP diff --git a/sprout/tuple/tuple/flexibly_construct.hpp b/sprout/tuple/tuple/flexibly_construct.hpp new file mode 100644 index 00000000..7ebffbf4 --- /dev/null +++ b/sprout/tuple/tuple/flexibly_construct.hpp @@ -0,0 +1,20 @@ +#ifndef SPROUT_TUPLE_TUPLE_FREXIBLY_CONSTRUCT_HPP +#define SPROUT_TUPLE_TUPLE_FREXIBLY_CONSTRUCT_HPP + +#include + +namespace sprout { + namespace tuples { + // + // flexibly_construct_t + // flexibly_construct + // + struct flexibly_construct_t {}; + SPROUT_STATIC_CONSTEXPR sprout::tuples::flexibly_construct_t flexibly_construct = {}; + } // namespace tuples + + using sprout::tuples::flexibly_construct_t; + using sprout::tuples::flexibly_construct; +} // namespace sprout + +#endif // #ifndef SPROUT_TUPLE_TUPLE_FREXIBLY_CONSTRUCT_HPP diff --git a/sprout/tuple/tuple/get.hpp b/sprout/tuple/tuple/get.hpp index a66743e7..144d9b2b 100644 --- a/sprout/tuple/tuple/get.hpp +++ b/sprout/tuple/tuple/get.hpp @@ -40,26 +40,23 @@ namespace sprout { : public std::tuple_element {}; template - struct tuple_element { - public: - typedef typename std::add_const< + struct tuple_element + : public std::add_const< typename sprout::tuples::tuple_element::type - >::type type; - }; + > + {}; template - struct tuple_element { - public: - typedef typename std::add_volatile< + struct tuple_element + : public std::add_volatile< typename sprout::tuples::tuple_element::type - >::type type; - }; + > + {}; template - struct tuple_element { - public: - typedef typename std::add_cv< + struct tuple_element + : public std::add_cv< typename sprout::tuples::tuple_element::type - >::type type; - }; + > + {}; namespace detail { template diff --git a/sprout/tuple/tuple/make_tuple.hpp b/sprout/tuple/tuple/make_tuple.hpp index 7dd9b1dd..4de14393 100644 --- a/sprout/tuple/tuple/make_tuple.hpp +++ b/sprout/tuple/tuple/make_tuple.hpp @@ -103,12 +103,11 @@ namespace sprout { typedef sprout::index_tuple<> type; }; template - struct tuple_cat_1st_indexes { - public: - typedef typename sprout::index_range< + struct tuple_cat_1st_indexes + : public sprout::index_range< 0, sprout::tuples::tuple_size::type>::value - >::type type; - }; + > + {}; template struct tuple_cat_impl; diff --git a/sprout/tuple/tuple/tuple.hpp b/sprout/tuple/tuple/tuple.hpp index 5017295c..ddc90233 100644 --- a/sprout/tuple/tuple/tuple.hpp +++ b/sprout/tuple/tuple/tuple.hpp @@ -9,8 +9,10 @@ #include #include #include +#include +#include #include -#include +#include namespace sprout { namespace tuples { @@ -247,32 +249,46 @@ namespace sprout { : inherited_type(elements...) {} template< - typename U, + typename... UTypes, typename = typename std::enable_if< - !sprout::tuples::is_tuple::type>::value + sizeof...(Types) == sizeof...(UTypes) && sprout::tpp::all_of...>::value >::type > - explicit SPROUT_CONSTEXPR tuple(U&& elem) - : inherited_type(sprout::forward(elem)) + explicit SPROUT_CONSTEXPR tuple(UTypes&&... elements) + : inherited_type(sprout::forward(elements)...) {} - template< - typename U1, - typename U2, - typename... UTypes - > - explicit SPROUT_CONSTEXPR tuple(U1&& elem1, U2&& elem2, UTypes&&... elements) - : inherited_type(sprout::forward(elem1), sprout::forward(elem2), sprout::forward(elements)...) + template + explicit SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, UTypes&&... elements) + : inherited_type(sprout::forward(elements)...) {} SPROUT_CONSTEXPR tuple(tuple const&) = default; SPROUT_CONSTEXPR tuple(tuple&&) = default; - template + template< + typename... UTypes, + typename = typename std::enable_if< + sizeof...(Types) == sizeof...(UTypes) && sprout::tpp::all_of...>::value + >::type + > SPROUT_CONSTEXPR tuple(sprout::tuples::tuple const& t) : inherited_type(static_cast const&>(t)) {} - template + template< + typename... UTypes, + typename = typename std::enable_if< + sizeof...(Types) == sizeof...(UTypes) && sprout::tpp::all_of...>::value + >::type + > SPROUT_CONSTEXPR tuple(sprout::tuples::tuple&& t) : inherited_type(static_cast&&>(t)) {} + template + SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::tuples::tuple const& t) + : inherited_type(static_cast const&>(t)) + {} + template + SPROUT_CONSTEXPR tuple(sprout::tuples::flexibly_construct_t, sprout::tuples::tuple&& t) + : inherited_type(static_cast&&>(t)) + {} // tuple assignment tuple& operator=(tuple const& rhs) { static_cast(*this) = rhs; diff --git a/sprout/type/iterator/advance.hpp b/sprout/type/iterator/advance.hpp index 95a887a0..50bc50cc 100644 --- a/sprout/type/iterator/advance.hpp +++ b/sprout/type/iterator/advance.hpp @@ -9,10 +9,9 @@ namespace sprout { // advance // template - struct advance { - public: - typedef typename Iterator::template advance::type type; - }; + struct advance + : public Iterator::template advance + {}; template struct advance diff --git a/sprout/type/iterator/deref.hpp b/sprout/type/iterator/deref.hpp index 7c1f139b..3b284ee4 100644 --- a/sprout/type/iterator/deref.hpp +++ b/sprout/type/iterator/deref.hpp @@ -9,10 +9,9 @@ namespace sprout { // deref // template - struct deref { - public: - typedef typename Iterator::type type; - }; + struct deref + : public Iterator + {}; } // namespace types } // namespace sprout diff --git a/sprout/type_traits.hpp b/sprout/type_traits.hpp index 29b3867d..a39e134e 100644 --- a/sprout/type_traits.hpp +++ b/sprout/type_traits.hpp @@ -2,6 +2,7 @@ #define SPROUT_TYPE_TRAITS_HPP #include +#include #include #include #include diff --git a/sprout/type_traits/is_convert_constructible.hpp b/sprout/type_traits/is_convert_constructible.hpp new file mode 100644 index 00000000..80fe50ca --- /dev/null +++ b/sprout/type_traits/is_convert_constructible.hpp @@ -0,0 +1,32 @@ +#ifndef SPROUT_TYPE_TRAITS_IS_CONVERT_CONSTRUCTIBLE_HPP +#define SPROUT_TYPE_TRAITS_IS_CONVERT_CONSTRUCTIBLE_HPP + +#include +#include +#include + +namespace sprout { + // + // is_convert_constructible + // + namespace detail { + template + struct is_convert_constructible_test { + public: + template + static std::true_type test(To); + static std::false_type test(...); + }; + } // namespace detail + template + struct is_convert_constructible + : public decltype(sprout::detail::is_convert_constructible_test::test(std::declval())) + {}; + +#if SPROUT_USE_TEMPLATE_ALIASES + template + using is_convert_constructible_ = typename sprout::is_convert_constructible::type; +#endif // #if SPROUT_USE_TEMPLATE_ALIASES +} // namespace sprout + +#endif // #ifndef SPROUT_TYPE_TRAITS_IS_CONVERT_CONSTRUCTIBLE_HPP diff --git a/sprout/utility/pack.hpp b/sprout/utility/pack.hpp index 7f259265..76aac868 100644 --- a/sprout/utility/pack.hpp +++ b/sprout/utility/pack.hpp @@ -13,10 +13,9 @@ namespace sprout { // namespace detail { template - struct tppack_at_impl_1 { - public: - typedef typename sprout::detail::tppack_at_impl_1::type type; - }; + struct tppack_at_impl_1 + : public sprout::detail::tppack_at_impl_1 + {}; template struct tppack_at_impl_1<0, Head, Tail...> { public: diff --git a/sprout/variant/variant.hpp b/sprout/variant/variant.hpp index 2b2a9291..9d8cff48 100644 --- a/sprout/variant/variant.hpp +++ b/sprout/variant/variant.hpp @@ -29,11 +29,12 @@ namespace sprout { friend class variant; protected: typedef sprout::tuples::tuple tuple_type; - typedef sprout::types::type_tuple::type...> uncvref_tuple_type; + typedef sprout::types::type_tuple::type...> decayed_tuple_type; private: template static SPROUT_CONSTEXPR tuple_type init(T&& operand, sprout::index_tuple) { return sprout::tuples::make( + sprout::tuples::flexibly_construct, typename sprout::tuples::tuple_element::type()..., sprout::forward(operand) ); @@ -72,28 +73,26 @@ namespace sprout { { private: typedef sprout::detail::variant_impl impl_type; - typedef typename impl_type::uncvref_tuple_type uncvref_tuple_type; + typedef typename impl_type::decayed_tuple_type decayed_tuple_type; public: typedef typename impl_type::tuple_type tuple_type; private: template struct visitor_result_impl_2; template - struct visitor_result_impl_2 > { - public: - typedef typename Visitor::template visitor_result< + struct visitor_result_impl_2 > + : public Visitor::template visitor_result< decltype((std::declval())(sprout::tuples::get(std::declval())))... - >::type type; - }; + > + {}; template struct visitor_result_impl_1; template - struct visitor_result_impl_1 > { - public: - typedef typename sprout::common_decay< + struct visitor_result_impl_1 > + : public sprout::common_decay< decltype((std::declval())(sprout::tuples::get(std::declval())))... - >::type type; - }; + > + {}; template struct visitor_result_impl; template @@ -227,7 +226,7 @@ namespace sprout { SPROUT_CONSTEXPR variant(T&& operand) : impl_type( sprout::forward(operand), - sprout::types::find_index::type>() + sprout::types::find_index::type>() ) {} // modifiers diff --git a/sprout/weed/expr/make_terminal.hpp b/sprout/weed/expr/make_terminal.hpp index 21107357..c3cdc05d 100644 --- a/sprout/weed/expr/make_terminal.hpp +++ b/sprout/weed/expr/make_terminal.hpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include @@ -17,7 +16,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::weed::traits::is_c_str< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::value, typename sprout::weed::traits::terminal_of::type >::type make_terminal(Arg&& arg) { @@ -28,7 +27,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::traits::is_c_str< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::value, typename sprout::weed::traits::terminal_of::type >::type make_terminal(Arg&& arg) { diff --git a/sprout/weed/expr/make_terminal_or_expr.hpp b/sprout/weed/expr/make_terminal_or_expr.hpp index 4070d753..cf340fe6 100644 --- a/sprout/weed/expr/make_terminal_or_expr.hpp +++ b/sprout/weed/expr/make_terminal_or_expr.hpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -17,7 +16,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename std::enable_if< sprout::weed::traits::is_expr< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::value, typename sprout::weed::traits::terminal_or_expr_of::type >::type make_terminal_or_expr(Arg&& arg) { @@ -26,7 +25,7 @@ namespace sprout { template inline SPROUT_CONSTEXPR typename std::enable_if< !sprout::weed::traits::is_expr< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::value, typename sprout::weed::traits::terminal_or_expr_of::type >::type make_terminal_or_expr(Arg&& arg) { diff --git a/sprout/weed/operator/address_of.hpp b/sprout/weed/operator/address_of.hpp index 2bdb56c4..0c36d1e3 100644 --- a/sprout/weed/operator/address_of.hpp +++ b/sprout/weed/operator/address_of.hpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -19,7 +18,7 @@ namespace sprout { typename Arg, typename = typename std::enable_if< sprout::weed::traits::is_parser< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::value >::type > diff --git a/sprout/weed/operator/bitwise_or.hpp b/sprout/weed/operator/bitwise_or.hpp index 84a0ea2b..176d1924 100644 --- a/sprout/weed/operator/bitwise_or.hpp +++ b/sprout/weed/operator/bitwise_or.hpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -20,10 +19,10 @@ namespace sprout { typename Arg2, typename = typename std::enable_if< sprout::weed::traits::is_parser< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::value && sprout::weed::traits::is_parser< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::value >::type > diff --git a/sprout/weed/operator/dereference.hpp b/sprout/weed/operator/dereference.hpp index 53e32a8b..0c3dd8a0 100644 --- a/sprout/weed/operator/dereference.hpp +++ b/sprout/weed/operator/dereference.hpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -19,7 +18,7 @@ namespace sprout { typename Arg, typename = typename std::enable_if< sprout::weed::traits::is_parser< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::value >::type > diff --git a/sprout/weed/operator/logical_not.hpp b/sprout/weed/operator/logical_not.hpp index eba98198..354d838b 100644 --- a/sprout/weed/operator/logical_not.hpp +++ b/sprout/weed/operator/logical_not.hpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -19,7 +18,7 @@ namespace sprout { typename Arg, typename = typename std::enable_if< sprout::weed::traits::is_parser< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::value >::type > diff --git a/sprout/weed/operator/mem_ptr.hpp b/sprout/weed/operator/mem_ptr.hpp index 7fe8f147..cf0d93b5 100644 --- a/sprout/weed/operator/mem_ptr.hpp +++ b/sprout/weed/operator/mem_ptr.hpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -20,7 +19,7 @@ namespace sprout { typename Arg2, typename = typename std::enable_if< sprout::weed::traits::is_parser< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::value >::type > diff --git a/sprout/weed/operator/minus.hpp b/sprout/weed/operator/minus.hpp index 9edfff43..defe576f 100644 --- a/sprout/weed/operator/minus.hpp +++ b/sprout/weed/operator/minus.hpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -20,10 +19,10 @@ namespace sprout { typename Arg2, typename = typename std::enable_if< sprout::weed::traits::is_parser< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::value && sprout::weed::traits::is_parser< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::value >::type > diff --git a/sprout/weed/operator/modulus.hpp b/sprout/weed/operator/modulus.hpp index e0b380fa..0882fc81 100644 --- a/sprout/weed/operator/modulus.hpp +++ b/sprout/weed/operator/modulus.hpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -20,10 +19,10 @@ namespace sprout { typename Arg2, typename = typename std::enable_if< sprout::weed::traits::is_parser< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::value && sprout::weed::traits::is_parser< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::value >::type > diff --git a/sprout/weed/operator/negate.hpp b/sprout/weed/operator/negate.hpp index a866961a..72bcd1cd 100644 --- a/sprout/weed/operator/negate.hpp +++ b/sprout/weed/operator/negate.hpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -19,7 +18,7 @@ namespace sprout { typename Arg, typename = typename std::enable_if< sprout::weed::traits::is_parser< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::value >::type > diff --git a/sprout/weed/operator/shift_left.hpp b/sprout/weed/operator/shift_left.hpp index 3124378f..05f3dac7 100644 --- a/sprout/weed/operator/shift_left.hpp +++ b/sprout/weed/operator/shift_left.hpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -20,10 +19,10 @@ namespace sprout { typename Arg2, typename = typename std::enable_if< sprout::weed::traits::is_parser< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::value && sprout::weed::traits::is_parser< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::value >::type > diff --git a/sprout/weed/operator/unary_plus.hpp b/sprout/weed/operator/unary_plus.hpp index c0646831..ce1a4939 100644 --- a/sprout/weed/operator/unary_plus.hpp +++ b/sprout/weed/operator/unary_plus.hpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -19,7 +18,7 @@ namespace sprout { typename Arg, typename = typename std::enable_if< sprout::weed::traits::is_parser< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::value >::type > diff --git a/sprout/weed/parser/lit.hpp b/sprout/weed/parser/lit.hpp index 6f96e2ab..7599291e 100644 --- a/sprout/weed/parser/lit.hpp +++ b/sprout/weed/parser/lit.hpp @@ -18,7 +18,8 @@ namespace sprout { template SPROUT_CONSTEXPR typename eval< typename sprout::remove_shallow_cvref::type - >::result_type operator()(T&& t) const { + >::result_type + operator()(T&& t) const { typedef eval::type> eval_type; return eval_type()(sprout::forward(t)); } diff --git a/sprout/weed/traits/expr/expr_of.hpp b/sprout/weed/traits/expr/expr_of.hpp index bad3daa9..68d62cf6 100644 --- a/sprout/weed/traits/expr/expr_of.hpp +++ b/sprout/weed/traits/expr/expr_of.hpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include @@ -20,7 +19,7 @@ namespace sprout { sprout::weed::expr< Tag, typename sprout::weed::traits::terminal_or_expr_of< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::type... > > diff --git a/sprout/weed/traits/expr/terminal_of.hpp b/sprout/weed/traits/expr/terminal_of.hpp index a4a630d7..aab7506e 100644 --- a/sprout/weed/traits/expr/terminal_of.hpp +++ b/sprout/weed/traits/expr/terminal_of.hpp @@ -23,7 +23,7 @@ namespace sprout { Arg, typename std::enable_if< !sprout::weed::traits::is_c_str< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::value >::type > @@ -39,7 +39,7 @@ namespace sprout { Arg, typename std::enable_if< sprout::weed::traits::is_c_str< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::value >::type > @@ -47,7 +47,7 @@ namespace sprout { sprout::weed::expr< sprout::weed::tag::terminal, typename sprout::weed::detail::c_str_as_string< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::type > > diff --git a/sprout/weed/traits/expr/terminal_or_expr_of.hpp b/sprout/weed/traits/expr/terminal_or_expr_of.hpp index 9470c998..c2fe8f76 100644 --- a/sprout/weed/traits/expr/terminal_or_expr_of.hpp +++ b/sprout/weed/traits/expr/terminal_or_expr_of.hpp @@ -17,7 +17,7 @@ namespace sprout { struct terminal_or_expr_of : public std::conditional< sprout::weed::traits::is_expr< - typename sprout::remove_shallow_cvref::type + typename std::remove_reference::type >::value, sprout::remove_shallow_cvref, sprout::weed::traits::terminal_of