Boost.Test check whether a pointer is null

后端 未结 2 1516
情话喂你
情话喂你 2021-01-12 05:56

I have the following test :

BOOST_CHECK_NE(pointer, nullptr);

The compilation fails due to

/xxx/include/boost/test

2条回答
  •  终归单人心
    2021-01-12 06:33

    As mentioned in error message, nullptr has ambiguous overloads.

    BOOST_CHECK(pointer);
    

    or

    BOOST_CHECK_NE(pointer, static_cast(nullptr));
    

    should do the job.

提交回复
热议问题