Boost logo

Boost :

Subject: [boost] [tti] compiler error: shadows template param `class T`
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2011-08-10 21:37:32


Hello,

The TTI library macros expand to code that uses naive template
parameter names like "T", "F", "U", etc. The library implementation
should be changed to use library reserved names to avoid clashing with
user template parameter names. For example, the library use a name
like boost_tti_aux_T (or even better BOOST_PP_CAT(boost_tti_aux_T_,
__LINE__)) instead of T and state in the documentation that any name
prefixed by boost_tti_aux (in any namespace) is reserved for the
library implementation. The same should be done for any other
implementation symbol defined by the TTI library.

This is an issue if the macros are expanded for example within a class
(which is and should be possible after changing them not to expand in
the boost::tti namespace). For example, assuming
BOOST_TTI_HAS_COMP_MEMBER_FUNCTION is fixed not to expand in
boost::tti then the following:

template< typename T >
struct myvector {
    BOOST_TTI_HAS_COMP_MEMBER_FUNCTION_TRAIT(has_push_back, push_back)
// expand to code using a template parameter naively named T
    ...
};

Will generate a compiler error on GCC "error: shadows template param class T".

--Lorenzo


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