From 0b79177d35d2a768acce3ab65cfd57a6a836d91a Mon Sep 17 00:00:00 2001 From: SunBlack Date: Wed, 23 Nov 2022 18:14:05 +0100 Subject: [PATCH] Replace BOOST_MPL_ASSERT by static_assert --- common/include/pcl/common/concatenate.h | 5 ++--- common/include/pcl/for_each_type.h | 4 ++-- common/include/pcl/point_struct_traits.h | 19 +++++++++---------- common/include/pcl/register_point_struct.h | 16 +++++++--------- 4 files changed, 20 insertions(+), 24 deletions(-) diff --git a/common/include/pcl/common/concatenate.h b/common/include/pcl/common/concatenate.h index f751081293b..01f5855a06f 100644 --- a/common/include/pcl/common/concatenate.h +++ b/common/include/pcl/common/concatenate.h @@ -63,9 +63,8 @@ namespace pcl using InT = typename pcl::traits::datatype::type; using OutT = typename pcl::traits::datatype::type; // Note: don't currently support different types for the same field (e.g. converting double to float) - BOOST_MPL_ASSERT_MSG ((std::is_same::value), - POINT_IN_AND_POINT_OUT_HAVE_DIFFERENT_TYPES_FOR_FIELD, - (Key, PointInT&, InT, PointOutT&, OutT)); + static_assert(std::is_same::value, + "PointInT and PointOutT have different types for field."); memcpy (reinterpret_cast(&p2_) + pcl::traits::offset::value, reinterpret_cast(&p1_) + pcl::traits::offset::value, sizeof (InT)); diff --git a/common/include/pcl/for_each_type.h b/common/include/pcl/for_each_type.h index fc5ca3502ab..9c3c4628c18 100644 --- a/common/include/pcl/for_each_type.h +++ b/common/include/pcl/for_each_type.h @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -90,7 +89,8 @@ namespace pcl template inline void for_each_type (F f) { - BOOST_MPL_ASSERT (( boost::mpl::is_sequence )); + static_assert(boost::mpl::is_sequence::type::value, + "Given type is not a valid sequence."); using first = typename boost::mpl::begin::type; using last = typename boost::mpl::end::type; for_each_type_impl::value>::template execute (f); diff --git a/common/include/pcl/point_struct_traits.h b/common/include/pcl/point_struct_traits.h index 1299d8132e8..7805aed1c26 100644 --- a/common/include/pcl/point_struct_traits.h +++ b/common/include/pcl/point_struct_traits.h @@ -37,7 +37,6 @@ #pragma once -#include // for BOOST_MPL_ASSERT_MSG #include // for boost::mpl::identity #include // for boost::mpl::vector @@ -45,7 +44,7 @@ #include // for BOOST_PP_TUPLE_ELEM #include // for BOOST_PP_STRINGIZE -// This is required for the workaround at line 84 +// This is required for the MSVC workaround below #ifdef _MSC_VER #include #include @@ -111,8 +110,8 @@ struct name /** \cond NO_WARN_RECURSIVE */ : name::type, Ta // static const char value[]; // Avoid infinite compile-time recursion - BOOST_MPL_ASSERT_MSG((!std::is_same::type>::value), - POINT_TYPE_NOT_PROPERLY_REGISTERED, (PointT&)); + static_assert(!std::is_same::type>::value, + "Point type not properly registered."); }; } // namespace traits } // namespace pcl @@ -143,8 +142,8 @@ struct offset /** \cond NO_WARN_RECURSIVE */ : offset::type // static const std::size_t value; // Avoid infinite compile-time recursion - BOOST_MPL_ASSERT_MSG((!std::is_same::type>::value), - POINT_TYPE_NOT_PROPERLY_REGISTERED, (PointT&)); + static_assert(!std::is_same::type>::value, + "Point type not properly registered."); }; } // namespace traits } // namespace pcl @@ -170,8 +169,8 @@ namespace traits // static const std::uint32_t size; // Avoid infinite compile-time recursion - BOOST_MPL_ASSERT_MSG((!std::is_same::type>::value), - POINT_TYPE_NOT_PROPERLY_REGISTERED, (PointT&)); + static_assert(!std::is_same::type>::value, + "Point type not properly registered."); }; } // namespace traits } // namespace pcl @@ -198,8 +197,8 @@ struct fieldList /** \cond NO_WARN_RECURSIVE */ : fieldList // using type = boost::mpl::vector<...>; // Avoid infinite compile-time recursion - BOOST_MPL_ASSERT_MSG((!std::is_same::type>::value), - POINT_TYPE_NOT_PROPERLY_REGISTERED, (PointT&)); + static_assert(!std::is_same::type>::value, + "Point type not properly registered."); }; } // namespace traits } // namespace pcl diff --git a/common/include/pcl/register_point_struct.h b/common/include/pcl/register_point_struct.h index 1a09228b834..f19152fe15c 100644 --- a/common/include/pcl/register_point_struct.h +++ b/common/include/pcl/register_point_struct.h @@ -51,7 +51,6 @@ #endif #include // for pcl::traits::POD, POINT_CLOUD_REGISTER_FIELD_(NAME, OFFSET, DATATYPE), POINT_CLOUD_REGISTER_POINT_FIELD_LIST -#include // for BOOST_MPL_ASSERT_MSG #include // for BOOST_PP_SEQ_FOR_EACH #include // for BOOST_PP_SEQ_TRANSFORM #include // for BOOST_PP_TUPLE_ELEM @@ -66,12 +65,13 @@ BOOST_PP_CAT(POINT_CLOUD_REGISTER_POINT_STRUCT_X fseq, 0)) /***/ -#define POINT_CLOUD_REGISTER_POINT_WRAPPER(wrapper, pod) \ - BOOST_MPL_ASSERT_MSG(sizeof(wrapper) == sizeof(pod), POINT_WRAPPER_AND_POD_TYPES_HAVE_DIFFERENT_SIZES, (wrapper&, pod&)); \ - namespace pcl { \ - namespace traits { \ - template<> struct POD { using type = pod; }; \ - } \ +#define POINT_CLOUD_REGISTER_POINT_WRAPPER(wrapper, pod) \ + static_assert(sizeof(wrapper) == sizeof(pod), \ + "Point wrapper and POD types have different sizes."); \ + namespace pcl { \ + namespace traits { \ + template<> struct POD { using type = pod; }; \ + } \ } /***/ @@ -248,8 +248,6 @@ namespace pcl /***/ // Construct type traits given full sequence of (type, name, tag) triples -// BOOST_MPL_ASSERT_MSG(std::is_pod::value, -// REGISTERED_POINT_TYPE_MUST_BE_PLAIN_OLD_DATA, (name)); #define POINT_CLOUD_REGISTER_POINT_STRUCT_I(name, seq) \ namespace pcl \ { \