c++boost.gif (8819 bytes)
Main Page   File List   File Members  

cat.hpp File Reference


Defines

#define BOOST_PREPROCESSOR_CAT(L, R)
 Delays the catenation of L and R. More...


Detailed Description

Click here to see the header.


Define Documentation

#define BOOST_PREPROCESSOR_CAT L,
 
 

Delays the catenation of L and R.

Example:

  #define STATIC_ASSERT(EXPR)\
    enum\
    { BOOST_PREPROCESSOR_CAT(static_check_,__LINE__) = (EXPR) ? 1 : -1\
    };\
    typedef char\
      BOOST_PREPROCESSOR_CAT(static_assert_,__LINE__)\
      [ BOOST_PREPROCESSOR_CAT(static_check_,__LINE__)\
      ]

  // ...

  STATIC_ASSERT(sizeof(int) <= sizeof(long));

The above expands to:

  enum
  { static_check_152 = (sizeof(int) <= sizeof(long)) ? 1 : -1
  };
  typedef char
    static_assert_152
    [ static_check_152
    ];

Using BOOST_PREPROCESSOR_CAT() above lets the preprocessor expand the __LINE__. If the above code would use the ## operator directly then __LINE__ would not be expanded and the above would expand to:

  enum
  { static_check___LINE__ = (sizeof(int) <= sizeof(long)) ? 1 : -1
  };
  typedef char
    static_assert___LINE__
    [ static_check___LINE__
    ];


© Copyright Housemarque, Inc. 2001

Permission to copy, use, modify, sell and distribute this document is granted provided this copyright notice appears in all copies. This document is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.

Generated: