From f0f24b48836d65af723c6a89dd43b91b94162a04 Mon Sep 17 00:00:00 2001 From: "Hintz Martin (XC-AD/ESW1-J1)" Date: Wed, 3 Mar 2021 14:47:04 +0100 Subject: [PATCH] iox-#591 Added void_t to type_traits Signed-off-by: Hintz Martin (XC-AD/ESW1-J1) --- .../include/iceoryx_utils/cxx/type_traits.hpp | 3 ++ .../iceoryx_utils/internal/cxx/expected.inl | 2 +- .../test/moduletests/test_cxx_type_traits.cpp | 38 +++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/iceoryx_utils/include/iceoryx_utils/cxx/type_traits.hpp b/iceoryx_utils/include/iceoryx_utils/cxx/type_traits.hpp index 2cfd0701e4..f0e180d4e0 100644 --- a/iceoryx_utils/include/iceoryx_utils/cxx/type_traits.hpp +++ b/iceoryx_utils/include/iceoryx_utils/cxx/type_traits.hpp @@ -72,6 +72,9 @@ template using not_same = typename std:: integral_constant::type, typename std::decay::type>::value)>; +/// @brief Maps a sequence of any types to the type void +template +using void_t = void; } // namespace cxx } // namespace iox diff --git a/iceoryx_utils/include/iceoryx_utils/internal/cxx/expected.inl b/iceoryx_utils/include/iceoryx_utils/internal/cxx/expected.inl index d9168657d3..a9495d1729 100644 --- a/iceoryx_utils/include/iceoryx_utils/internal/cxx/expected.inl +++ b/iceoryx_utils/include/iceoryx_utils/internal/cxx/expected.inl @@ -29,7 +29,7 @@ struct HasInvalidStateMember : std::false_type { }; template -struct HasInvalidStateMember> : std::true_type +struct HasInvalidStateMember> : std::true_type { }; template diff --git a/iceoryx_utils/test/moduletests/test_cxx_type_traits.cpp b/iceoryx_utils/test/moduletests/test_cxx_type_traits.cpp index 8609d1e36e..5f7e0c2ff8 100644 --- a/iceoryx_utils/test/moduletests/test_cxx_type_traits.cpp +++ b/iceoryx_utils/test/moduletests/test_cxx_type_traits.cpp @@ -59,3 +59,41 @@ TEST(TypeTraitsTest, NotSameIsFalse) auto sut = not_same::value; EXPECT_FALSE(sut); } + +namespace iox +{ +namespace cxx +{ +namespace test +{ +template +struct has_mytype_as_member : std::false_type +{ +}; + +template +struct has_mytype_as_member> : std::true_type +{ +}; +} // namespace test +} // namespace cxx +} // namespace iox + +TEST(TypeTraitsTest, NoTypeAsMemberIsFalse) +{ + struct Sut + { + }; + + EXPECT_FALSE(iox::cxx::test::has_mytype_as_member::value); +} + +TEST(TypeTraitsTest, MyTypeAsMemberIsTrue) +{ + struct Sut + { + using myType = int; + }; + + EXPECT_TRUE(iox::cxx::test::has_mytype_as_member::value); +}