Boost logo

Boost :

Subject: [boost] nested function templates on GCC
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2012-09-30 13:18:32


Hi,

Currently I'm working on a spatial index and was considering using
methods templates until I've tested it on GCC. Consider the following
simple example:

template <typename T1, typename T2>
struct boom {};

struct aaa
{
     template <typename T>
     void boom() {}
};

template <typename T>
struct bbb
{
     void test()
     {
         T t;
         t.template boom<int>(); // <- here GCC resolves struct boom
     }
};

This kind of code is already used in Boost. Try to compile this on GCC:

template <typename T1, typename T2> struct apply {};
template <typename T1, typename T2> struct replace {};
template <typename T1, typename T2> struct remove_if {};
template <typename T1, typename T2> struct transfer {};
template <typename T1, typename T2> struct convert_to_container {};
template <typename T1, typename T2> struct push_match {};

#include <boost/optional.hpp>
#include <boost/ptr_container/ptr_array.hpp>
#include <boost/ptr_container/ptr_list.hpp>
#include <boost/assign.hpp>
#include <boost/xpressive/xpressive.hpp>

This is not the case on VC++ or clang. Also, not the case if structs
can't be found by the compiler (e.g. are in the different namespace).
But what if some library defines some struct template and includes other
library which defines method template with the same name? Is GCC
standard-compliant in this case?

Regards,
Adam


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