Boost logo

Boost :

From: Serguei KOLOS (Serguei.Kolos_at_[hidden])
Date: 2006-02-21 03:41:44


Hello

Using the BOOST_PP_IS_EMPTY macro with string literal as parameter
causes compiler warning:
warning: pasting "BOOST_PP_IS_EMPTY_DEF_" and ""AA"" does not give a valid preprocessing token

In order to avoid this warning I have reimplemented this macro
as it is shown below. Could something similar be implemented by
the preprocessor library.

Cheers,
Sergei

#include <boost/preprocessor/if.hpp>
#include <boost/preprocessor/tuple.hpp>
#include <boost/preprocessor/facilities/is_empty.hpp>

#define MY_BOOST_PP_IS_EMPTY(x) MY_BOOST_PP_IS_EMPTY_I(MY_BOOST_PP_IS_EMPTY_HELPER x)
#define MY_BOOST_PP_IS_EMPTY_I(contents) MY_BOOST_PP_IS_EMPTY_II( contents() )
#define MY_BOOST_PP_IS_EMPTY_II(contents) MY_BOOST_PP_IS_EMPTY_III( contents )
#define MY_BOOST_PP_IS_EMPTY_III(contents) BOOST_PP_TUPLE_ELEM( 2, 0, ( MY_BOOST_PP_IS_EMPTY_DEF_ ## contents ) )
#define MY_BOOST_PP_IS_EMPTY_HELPER() MY_BOOST_PP_IS_EMPTY_TRUE
#define MY_BOOST_PP_IS_EMPTY_DEF_MY_BOOST_PP_IS_EMPTY_TRUE 1 ,
#define MY_BOOST_PP_IS_EMPTY_DEF_MY_BOOST_PP_IS_EMPTY_HELPER 0 ,

#define TEST_CASE_1( x ) BOOST_PP_IF( BOOST_PP_IS_EMPTY( x ), is empty, x )
#define TEST_CASE_2( x ) BOOST_PP_IF( MY_BOOST_PP_IS_EMPTY( x ), is empty, x )

TEST_CASE_1( "" )
TEST_CASE_1( "AA" )
TEST_CASE_1( AA )
TEST_CASE_1( )

TEST_CASE_2( "" )
TEST_CASE_2( "AA" )
TEST_CASE_2( AA )
TEST_CASE_2( )


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk