Boost logo

Boost :

From: Daniel James (daniel_at_[hidden])
Date: 2005-10-09 04:08:05

A. Azuma wrote:
> I use a subtle implementation of compile-time global counter to emulate
> auto/decltype, and subtly hides them in FOREACH macro and iterator syntax.
> Please see the attached code for more detail. The attached code has been tested
> on GCC3.4.2, MSVC7.1 and MSVC8.0 beta 2. All the implementations are
> compliant to the standard, I believe so at least.

Unfortunately, this technique is not standards compliant. The problem is
in this code:

template<int n>
struct test_auto_range_count_injector
   friend char (&test_auto_range_count(auto_range_count_tag<n>))[n];

sizeof( \
   ::foreach_detail::test_auto_range_count( \
     ::foreach_detail::auto_range_end_of_count_tag() \
   ) \

On a strictly standards compliant compiler, a friend function that is
only declared inside a class is found using argument dependant lookup -
the compiler knows to look inside the class because one of it's
parameters is the class (or a descendant of it). Here there is no such
parameter so the compiler doesn't know that it needs to look in

As far as I know the only compilers that work that way are EDG based
compilers (eg. Intel, Comeau) in strict mode. This technique will work
on EDG compilers if strict mode isn't on.

The same applies to the friend funcions in auto_iterator<id, Iterator>.


Boost list run by bdawes at, gregod at, cpdaniel at, john at