|
Boost : |
From: Hartmut Kaiser (hartmutkaiser_at_[hidden])
Date: 2003-09-03 14:17:05
Daniel Frey wrote:
> > The current version of the file type_with_alignment.hpp
> gives spourios
> > errors, because some macro expansion code generates '>>'
> instead of '>
> >
> >>' (closing template brackets). The corresponding fixing patch is
> >
> > attached.
>
> Just out of curiousity: Is this a workaround for a compiler
> bug? I think
> I remember that if generated by the preprocessor, tokens need to be
> glued with ## to form a single new token like >>, otherwise even two
> consecutive >'s will be treated like two tokens. My colleague
> says I'm
> wrong. Am I? :)
Concatenating two tokens with the '##' operator, where the result isn't
a new valid token results in undefined behaviour. In your sample it
yields '>>', which is a valid token, so it is well defined. In other
contexts two consecutive '>' characters are always interpreted as '>>'
and not as two single '>'.
But this isn't the point here. The '>>' was not formend by a '##'
operator but by plain consecutiveness:
#define SOME_MACRO(T) <T>
SOME_MACRO(some_class<...>) // expands to <some_class<...>>
But it should be <some_class<...> >
Regards Hartmut
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk