Files
boost_preprocessor/include/boost/preprocessor/empty.hpp

73 lines
1.9 KiB
C++
Raw Normal View History

2001-11-25 18:32:11 +00:00
#ifndef BOOST_PREPROCESSOR_EMPTY_HPP
#define BOOST_PREPROCESSOR_EMPTY_HPP
/* Copyright (C) 2001
* Housemarque Oy
* http://www.housemarque.com
*
* Permission to copy, use, modify, sell and distribute this software is
* granted provided this copyright notice appears in all copies. This
* software is provided "as is" without express or implied warranty, and
* with no claim as to its suitability for any purpose.
*
* See http://www.boost.org for most recent version.
*/
2002-01-31 14:21:31 +00:00
/** <P>Expands to nothing. Used with BOOST_PP_IF() and as an unused parameter.</P>
2001-11-25 18:32:11 +00:00
2002-01-31 14:21:31 +00:00
<P>Example usage as the implementation of BOOST_PP_COMMA_IF(C):</P>
2001-11-25 18:32:11 +00:00
2002-01-31 14:21:31 +00:00
<PRE>
#define BOOST_PP_COMMA_IF(C)\
BOOST_PP_IF(C,BOOST_PP_COMMA,BOOST_PP_EMPTY)()
2002-01-31 14:21:31 +00:00
</PRE>
2001-11-25 18:32:11 +00:00
2002-01-31 14:21:31 +00:00
<P>Example usage as an unused macro parameter:</P>
2001-11-25 18:32:11 +00:00
2002-01-31 14:21:31 +00:00
<PRE>
#define BOOST_PP_DEF(CV)\
2002-01-31 14:21:31 +00:00
template<class base>\
CV() typename implement_subscript_using_begin_subscript<base>::value_type&\
2001-11-25 18:32:11 +00:00
implement_subscript_using_begin_subscript<base>::operator[]\
2002-01-31 14:21:31 +00:00
( index_type\
i\
) CV()\
{ return base::begin()[i];\
2001-11-25 18:32:11 +00:00
}
2002-01-31 14:21:31 +00:00
BOOST_PP_DEF(BOOST_PP_EMPTY)
BOOST_PP_DEF(const BOOST_PP_EMPTY)
#undef BOOST_PP_DEF
2002-01-31 14:21:31 +00:00
</PRE>
2001-11-25 18:32:11 +00:00
2002-01-31 14:21:31 +00:00
<P>The above expands to:</P>
2001-11-25 18:32:11 +00:00
2002-01-31 14:21:31 +00:00
<PRE>
2001-11-25 18:32:11 +00:00
template<class base>
typename implement_subscript_using_begin_subscript<base>::value_type&
implement_subscript_using_begin_subscript<base>::operator[]
( index_type
i
)
{ return base::begin()[i];
}
template<class base>
const typename implement_subscript_using_begin_subscript<base>::value_type&
implement_subscript_using_begin_subscript<base>::operator[]
( index_type
i
) const
{ return base::begin()[i];
}
2002-01-31 14:21:31 +00:00
</PRE>
2001-11-25 18:32:11 +00:00
2002-01-31 14:21:31 +00:00
<P>In case you wonder, the above code is part of a generalized layer for
implementing the subscripting operators of a random access container.</P>
2001-11-25 18:32:11 +00:00
*/
#define BOOST_PP_EMPTY()
2002-01-31 14:21:31 +00:00
/** <P>Obsolete. Use BOOST_PP_EMPTY().</P> */
2001-11-25 18:32:11 +00:00
#define BOOST_PREPROCESSOR_EMPTY()
#endif