Skip to content

Commit

Permalink
Replace BOOST_MPL_ASSERT by static_assert
Browse files Browse the repository at this point in the history
  • Loading branch information
SunBlack committed Nov 23, 2022
1 parent 58f9cfb commit 5752b6e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
5 changes: 2 additions & 3 deletions common/include/pcl/common/concatenate.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ namespace pcl
using InT = typename pcl::traits::datatype<PointInT, Key>::type;
using OutT = typename pcl::traits::datatype<PointOutT, Key>::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<InT, OutT>::value),
POINT_IN_AND_POINT_OUT_HAVE_DIFFERENT_TYPES_FOR_FIELD,
(Key, PointInT&, InT, PointOutT&, OutT));
static_assert(std::is_same<InT, OutT>::value,
"PointInT and PointOutT have different types for field.");
memcpy (reinterpret_cast<std::uint8_t*>(&p2_) + pcl::traits::offset<PointOutT, Key>::value,
reinterpret_cast<const std::uint8_t*>(&p1_) + pcl::traits::offset<PointInT, Key>::value,
sizeof (InT));
Expand Down
3 changes: 2 additions & 1 deletion common/include/pcl/for_each_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ namespace pcl
template<typename Sequence, typename F> inline void
for_each_type (F f)
{
BOOST_MPL_ASSERT (( boost::mpl::is_sequence<Sequence> ));
static_assert(boost::mpl::is_sequence<Sequence>::type::value,
"Given type is not a valid sequence.");
using first = typename boost::mpl::begin<Sequence>::type;
using last = typename boost::mpl::end<Sequence>::type;
for_each_type_impl<std::is_same<first, last>::value>::template execute<first, last, F> (f);
Expand Down
17 changes: 8 additions & 9 deletions common/include/pcl/point_struct_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

#pragma once

#include <boost/mpl/assert.hpp> // for BOOST_MPL_ASSERT_MSG
#include <boost/mpl/identity.hpp> // for boost::mpl::identity

#include <boost/mpl/vector.hpp> // for boost::mpl::vector
Expand Down Expand Up @@ -111,8 +110,8 @@ struct name /** \cond NO_WARN_RECURSIVE */ : name<typename POD<PointT>::type, Ta
// static const char value[];

// Avoid infinite compile-time recursion
BOOST_MPL_ASSERT_MSG((!std::is_same<PointT, typename POD<PointT>::type>::value),
POINT_TYPE_NOT_PROPERLY_REGISTERED, (PointT&));
static_assert(!std::is_same<PointT, typename POD<PointT>::type>::value,
"Point type not properly registered.");
};
} // namespace traits
} // namespace pcl
Expand Down Expand Up @@ -143,8 +142,8 @@ struct offset /** \cond NO_WARN_RECURSIVE */ : offset<typename POD<PointT>::type
// static const std::size_t value;

// Avoid infinite compile-time recursion
BOOST_MPL_ASSERT_MSG((!std::is_same<PointT, typename POD<PointT>::type>::value),
POINT_TYPE_NOT_PROPERLY_REGISTERED, (PointT&));
static_assert(!std::is_same<PointT, typename POD<PointT>::type>::value,
"Point type not properly registered.");
};
} // namespace traits
} // namespace pcl
Expand All @@ -170,8 +169,8 @@ namespace traits
// static const std::uint32_t size;

// Avoid infinite compile-time recursion
BOOST_MPL_ASSERT_MSG((!std::is_same<PointT, typename POD<PointT>::type>::value),
POINT_TYPE_NOT_PROPERLY_REGISTERED, (PointT&));
static_assert(!std::is_same<PointT, typename POD<PointT>::type>::value,
"Point type not properly registered.");
};
} // namespace traits
} // namespace pcl
Expand All @@ -198,8 +197,8 @@ struct fieldList /** \cond NO_WARN_RECURSIVE */ : fieldList<typename POD<PointT>
// using type = boost::mpl::vector<...>;

// Avoid infinite compile-time recursion
BOOST_MPL_ASSERT_MSG((!std::is_same<PointT, typename POD<PointT>::type>::value),
POINT_TYPE_NOT_PROPERLY_REGISTERED, (PointT&));
static_assert(!std::is_same<PointT, typename POD<PointT>::type>::value,
"Point type not properly registered.");
};
} // namespace traits
} // namespace pcl
Expand Down
16 changes: 7 additions & 9 deletions common/include/pcl/register_point_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
#endif

#include <pcl/point_struct_traits.h> // for pcl::traits::POD, POINT_CLOUD_REGISTER_FIELD_(NAME, OFFSET, DATATYPE), POINT_CLOUD_REGISTER_POINT_FIELD_LIST
#include <boost/mpl/assert.hpp> // for BOOST_MPL_ASSERT_MSG
#include <boost/preprocessor/seq/for_each.hpp> // for BOOST_PP_SEQ_FOR_EACH
#include <boost/preprocessor/seq/transform.hpp> // for BOOST_PP_SEQ_TRANSFORM
#include <boost/preprocessor/tuple/elem.hpp> // for BOOST_PP_TUPLE_ELEM
Expand All @@ -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<wrapper> { 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<wrapper> { using type = pod; }; \
} \
}
/***/

Expand Down Expand Up @@ -248,8 +248,6 @@ namespace pcl
/***/

// Construct type traits given full sequence of (type, name, tag) triples
// BOOST_MPL_ASSERT_MSG(std::is_pod<name>::value,
// REGISTERED_POINT_TYPE_MUST_BE_PLAIN_OLD_DATA, (name));
#define POINT_CLOUD_REGISTER_POINT_STRUCT_I(name, seq) \
namespace pcl \
{ \
Expand Down

0 comments on commit 5752b6e

Please sign in to comment.