http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55576
Antony Polukhin <antoshkka at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
--- Comment #3 from Antony Polukhin <antoshkka at gmail dot com> 2012-12-04
07:12:12 UTC ---
(In reply to comment #1)
> I don't think this is a G++ bug, there are three problems with this code:
>
> 1) You need to #include <new> to use placement new
> 2) factory::apply is non-const but the parameter 'f' is const
Fixed
> 3) f.template apply<T> finds the current instantiation, ::apply<T>, rather
> than
> the member function you are trying to call, use f.FactoryT::template apply<T>
> instead
That is the point. `f.template apply<T>(address);` is accepted by some
compilers without `FactoryT::`
Fixed version:
struct factory {
template <typename T>
void * apply(void * address) const {
return 0;
}
};
template <typename T>
struct apply {
template <typename FactoryT>
void* operator()(FactoryT const& f, void * address) const {
return f.template apply<T>(address); // error: invalid use of ‘struct
apply<T>’ why???
}
};
int main() {
int place;
apply<int>()(factory(), &place);
return 0;
}