Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace BOOST_MPL_ASSERT by static_assert #5525

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SunBlack
Copy link
Contributor

When the static code analysis of MSVC is enabled, you are getting a lot of messages like:

C:\dev\pcl\common\include\pcl\common\concatenate.h(66): warning C26814: The const variable '`pcl::NdConcatenateFunctor<pcl::PointWithScale,pcl::PointXYZ>::operator()<pcl::fields::x>'::`2'::mpl_assertion_in_line_22' can be computed at compile-time. Consider using constexpr (con.5).
C:\dev\pcl\tracking\include\pcl\tracking\tracking.h(90): warning C26814: The const variable 'mpl_assertion_in_line_53' can be computed at compile-time. Consider using constexpr (con.5).

The reason is that the BOOST_MPL_ASSERT macros are for pre C++11, where static_assert didn't exists. Sadly these macros are still using static variable (see implementation of BOOST_MPL_ASSERT_MSG_IMPL).

This small MR reduces the number of warnings during compilation by 221 unique messages (with duplicates 5.778).

Split from #5522 as it changes the compiler output, so in case there will be some discussion.

Output with Boost implementation:

error C2664: 'int boost::mpl::assertion_failed<false>(boost::mpl::assert<false>::type)': cannot convert argument 1 from 'boost::mpl::failed ************(__cdecl pcl::NdConcatenateFunctor<PointInT,PointOutT>::()::POINT_IN_AND_POINT_OUT_HAVE_DIFFERENT_TYPES_FOR_FIELD::* ***********)(Key,PointInT &,InT,PointOutT &,OutT)' to 'boost::mpl::assert<false>::type'
        with
        [
            PointInT=pcl::PointXYZRGBNormal,
            PointOutT=pcl::PointXYZ,
            Key=arg
        ]

Output with static_assert:

error C2338: static_assert failed: 'PointInT and PointOutT have different types for field.'

@mvieth
Copy link
Member

mvieth commented Dec 26, 2022

I have to say, I find the output of BOOST_MPL_ASSERT a lot more informative/helpful since it also prints the types. Especially in concatenate.h this makes quite a difference IMO.
The change in for_each_type.h is fine by me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants