Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2000-11-07 00:12:54


Should the #if and #else parts be switched, so the usual case (the bad stuff
is not #defined) goes first? (The Boolean test gets inverted, of course.)
This is from an altered version of "operators.hpp," from version 10 of my
"dlw_oprs.zip" file in the Boost vault.

> // BOOST_IMPORT_TEMPLATE1 .. BOOST_IMPORT_TEMPLATE4 -
> //
> // When BOOST_NO_OPERATORS_IN_NAMESPACE is defined we need a way to import
> // an operator template into the boost namespace. BOOST_IMPORT_TEMPLATE1 is
> // used for one-argument forms of operator templates; BOOST_IMPORT_TEMPLATE2
> // for two-argument forms. Note that these macros expect to be invoked from
> // within boost.
>
> #if defined(BOOST_NO_OPERATORS_IN_NAMESPACE)
>
> # if defined(BOOST_NO_USING_TEMPLATE)
>
> // Because a Borland C++ 5.5 bug prevents a using declaration from working,
> // we are forced to use inheritance for that compiler.
> # define BOOST_IMPORT_TEMPLATE4(template_name) \
> template <class T, class U, class V, class W, class B =
> ::boost::detail::empty_base> \
> struct template_name : ::template_name<T, U, V, W, B> {};
>
> # define BOOST_IMPORT_TEMPLATE3(template_name) \
> template <class T, class U, class V, class B = ::boost::detail::empty_base>\
> struct template_name : ::template_name<T, U, V, B> {};
>
> # define BOOST_IMPORT_TEMPLATE2(template_name) \
> template <class T, class U, class B = ::boost::detail::empty_base> \
> struct template_name : ::template_name<T, U, B> {};
>
> # define BOOST_IMPORT_TEMPLATE1(template_name) \
> template <class T, class B = ::boost::detail::empty_base> \
> struct template_name : ::template_name<T, B> {};
>
> # else
>
> // Otherwise, bring the names in with a using-declaration to avoid
> // stressing the compiler
> # define BOOST_IMPORT_TEMPLATE4(template_name) using ::template_name;
> # define BOOST_IMPORT_TEMPLATE3(template_name) using ::template_name;
> # define BOOST_IMPORT_TEMPLATE2(template_name) using ::template_name;
> # define BOOST_IMPORT_TEMPLATE1(template_name) using ::template_name;
>
> # endif // BOOST_NO_USING_TEMPLATE
>
> #else // !BOOST_NO_OPERATORS_IN_NAMESPACE
>
> // The template is already in boost so we have nothing to do.
> # define BOOST_IMPORT_TEMPLATE4(template_name)
> # define BOOST_IMPORT_TEMPLATE3(template_name)
> # define BOOST_IMPORT_TEMPLATE2(template_name)
> # define BOOST_IMPORT_TEMPLATE1(template_name)
>
> #endif // BOOST_NO_OPERATORS_IN_NAMESPACE

-- 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com

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