diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..567609b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/.gitmodules b/.gitmodules index a89889c..19d788d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "cmake/modules"] path = cmake/modules - url = b3rgmann@git.bergmann89.de:cpp/CmakeModules.git + url = https://git.bergmann89.de/cpp/CmakeModules.git diff --git a/CMakeLists.txt b/CMakeLists.txt index a0512dd..6e565e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,6 @@ EndIf ( ) # Project ######################################################################################### -Include ( CTest ) Include ( GNUInstallDirs ) Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppmp-options.cmake ) Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppmp-const.cmake ) @@ -28,6 +27,7 @@ Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppmp-var. Project ( ${CPPMP_PROJECT_NAME} DESCRIPTION "${CPPMP_PROJECT_DESCRIPTION}" VERSION "${CPPMP_VERSION}" ) +Include ( CTest ) # Subdirectories Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/src ) diff --git a/cmake/cppmp-const.cmake b/cmake/cppmp-const.cmake index 2951638..a848bd1 100644 --- a/cmake/cppmp-const.cmake +++ b/cmake/cppmp-const.cmake @@ -23,6 +23,6 @@ Set ( CPPMP_INSTALL_DIR_SHARE "${CMAKE_INSTALL # C Standard Set ( CMAKE_C_STANDARD 11 ) -Set ( CMAKE_CXX_STANDARD 17 ) +Set ( CMAKE_CXX_STANDARD 14 ) Set ( CMAKE_C_STANDARD_REQUIRED ON ) Set ( CMAKE_CXX_STANDARD_REQUIRED ON ) diff --git a/include/cppmp/core/constants.h b/include/cppmp/core/constants.h index 967033f..694b792 100644 --- a/include/cppmp/core/constants.h +++ b/include/cppmp/core/constants.h @@ -1,4 +1,4 @@ -#pragma onec +#pragma once #include "types.h" diff --git a/include/cppmp/misc/getter.inl b/include/cppmp/misc/getter.inl index 907322e..ce40246 100644 --- a/include/cppmp/misc/getter.inl +++ b/include/cppmp/misc/getter.inl @@ -84,8 +84,8 @@ namespace cppmp struct getter_member_func : public tag_getter { - using object_type = T_object; - using value_type = T_value; + using object_type = decay_t; + using value_type = decay_t; using member_type = T_member; member_type member; @@ -168,6 +168,55 @@ namespace cppmp { return getter_lambda(std::forward(lambda)); } }; + /* getter_builder - chain */ + + template + struct getter_builder< + list, + enable_if_t< + is_valid_v()))> + && is_valid_v(), std::declval()...))> + > + > + { + struct getter_chain + : public tag_getter + { + using first_getter_type = decltype(make_getter(std::declval())); + using second_getter_type = decltype(make_getter(std::declval(), std::declval()...)); + using object_type = typename first_getter_type::object_type; + using value_type = typename second_getter_type::value_type;; + + first_getter_type first; + second_getter_type second; + + constexpr getter_chain( + first_getter_type&& p_first, + second_getter_type&& p_second) + : first (std::move(p_first)) + , second(std::move(p_second)) + { } + + constexpr getter_chain(getter_chain&&) = default; + constexpr getter_chain(const getter_chain&) = default; + + constexpr getter_chain& operator = (getter_chain&&) = default; + constexpr getter_chain& operator = (const getter_chain&) = default; + + template + constexpr decltype(auto) operator()(X_object&& obj) const + { return second(first(std::forward(obj))); } + }; + + template + static constexpr decltype(auto) apply(X_first&& first, X_rest&&... rest) + { + return getter_chain( + make_getter(std::forward(first)), + make_getter(std::forward(rest)...)); + } + }; + } /* is_getter */ diff --git a/include/cppmp/misc/setter.inl b/include/cppmp/misc/setter.inl index f45047b..6574aad 100644 --- a/include/cppmp/misc/setter.inl +++ b/include/cppmp/misc/setter.inl @@ -83,8 +83,8 @@ namespace cppmp struct setter_member_func : public tag_setter { - using object_type = T_object; - using value_type = T_value; + using object_type = decay_t; + using value_type = decay_t; using member_type = T_member; member_type member; @@ -101,7 +101,7 @@ namespace cppmp template constexpr void operator()(X_object&& obj, X_value&& value) const - { (std::forward(obj).*member)(value); } + { (std::forward(obj).*member)(std::forward(value)); } }; using object_type = T_object; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c284fb9..868e672 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -45,7 +45,7 @@ ForEach ( FILE IN LISTS CPPMP_TEST_SOURCE_FILES ) # test If ( HAS_CMAKE_TESTS ) - Add_CMake_Test ( NAME ${TEST_NAME} TARGET ${TEST_NAME} ) + Add_CMake_Test ( NAME ${TEST_NAME} TARGET ${TEST_NAME} GROUP cppmp ) Else ( ) Add_Test ( NAME ${TEST_NAME} COMMAND ${TEST_NAME} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) EndIf ( ) diff --git a/test/cppmp/cppmp_traits_test.cpp b/test/cppmp/cppmp_traits_test.cpp index ee0776c..505216b 100644 --- a/test/cppmp/cppmp_traits_test.cpp +++ b/test/cppmp/cppmp_traits_test.cpp @@ -12,44 +12,62 @@ struct test_obj static std::string sget(); }; -constexpr decltype(auto) cpp_traits_lambda = [](std::string, int)->bool { return true; }; +const test_obj& static_fuu() +{ + static const test_obj value; + return value; +} + +decltype(auto) cpp_traits_lambda = [](std::string, int)->bool { return true; }; using type0 = ::cppmp::lambda_traits; using type1 = ::cppmp::lambda_traits; using type2 = ::cppmp::lambda_traits; using type3 = ::cppmp::lambda_traits; using type4 = ::cppmp::lambda_traits; +using type5 = ::cppmp::lambda_traits; + +static_assert(is_same_v, ""); +static_assert(is_same_v, ""); +static_assert(is_same_v>, ""); +static_assert( type0::is_mutable_v == true, ""); +static_assert( type0::is_static_v == false, ""); +static_assert( type0::argument_count_v == 1, ""); + +static_assert(is_same_v, ""); +static_assert(is_same_v, ""); +static_assert(is_same_v>, ""); +static_assert( type1::is_mutable_v == false, ""); +static_assert( type1::is_static_v == false, ""); +static_assert( type1::argument_count_v == 2, ""); + +static_assert(is_same_v, ""); +static_assert(is_same_v, ""); +static_assert(is_same_v>, ""); +static_assert( type2::is_mutable_v == false, ""); +static_assert( type2::is_static_v == true, ""); +static_assert( type2::argument_count_v == 0, ""); -static_assert(is_same_v); -static_assert(is_same_v); -static_assert(is_same_v>); -static_assert( type0::is_mutable_v == true); -static_assert( type0::is_static_v == false); -static_assert( type0::argument_count_v == 1); - -static_assert(is_same_v); -static_assert(is_same_v); -static_assert(is_same_v>); -static_assert( type1::is_mutable_v == false); -static_assert( type1::is_static_v == false); -static_assert( type1::argument_count_v == 2); - -static_assert(is_same_v); -static_assert(is_same_v); -static_assert(is_same_v>); -static_assert( type2::is_mutable_v == false); -static_assert( type2::is_static_v == true); -static_assert( type2::argument_count_v == 0); - -static_assert(is_same_v); -static_assert(is_same_v); -static_assert(is_same_v>); -static_assert( type3::is_mutable_v == false); -static_assert( type3::is_static_v == true); -static_assert( type3::argument_count_v == 1); - -static_assert(is_same_v); -static_assert(is_same_v>); -static_assert( type4::is_mutable_v == false); -static_assert( type4::is_static_v == false); -static_assert( type4::argument_count_v == 2); +static_assert(is_same_v, ""); +static_assert(is_same_v, ""); +static_assert(is_same_v>, ""); +static_assert( type3::is_mutable_v == false, ""); +static_assert( type3::is_static_v == true, ""); +static_assert( type3::argument_count_v == 1, ""); + +static_assert(is_same_v, ""); +static_assert(is_same_v>, ""); +static_assert( type4::is_mutable_v == false, ""); +static_assert( type4::is_static_v == false, ""); +static_assert( type4::argument_count_v == 2, ""); + +static_assert(is_same_v, ""); +static_assert(is_same_v>, ""); +static_assert( type5::is_mutable_v == false, ""); +static_assert( type5::is_static_v == true, ""); +static_assert( type5::argument_count_v == 0, ""); + +TEST(cppmp_traits_test, dummy) +{ + (void)cpp_traits_lambda; +}