By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,193 Members | 843 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,193 IT Pros & Developers. It's quick & easy.

Scope resolution in needed to call a functor maker

P: n/a
I don't have to provide scope resolution in sit 0 below: adl
finds the function that I mean to use.

I do have to provide scope resolution in sits 1 and 2.

Can anyone teach me a trick to get around the need for scope resolution
in sit 1 or sit 2?

sit 1 is my motivating case, but if there's a trick for sit 2 I'd like
to know it too.

#include <iostream>
using namespace std;

// minimalist functor
template < typename xCallable, typename xResult >
struct ftor
typedef xCallable tCallable;
typedef xResult tResult;
ftor(const ftor & fThat):cCallable(fThat.cCallable){}
explicit ftor(tCallable fCallable):cCallable(fCallable){}
template < typename xArg > tResult operator()(xArg fArg) const
{return cCallable(fArg);}
tCallable cCallable;

// functor maker
template < typename xResult, typename xArg >
ftor< xResult (*)(xArg), xResult >
make_ftor(xResult (*fPtrFunc)(xArg))
{return ftor< xResult (*)(xArg), xResult >(fPtrFunc);}

// class and function that uses it
namespace A
class a{};
a func(a fA){cout << "::A::func" << endl; return fA;}

int main()
typedef A::a tA;
typedef tA (*tPtrFunc)(tA);

tA fA;

// sit 0 - Finds through adl

// sit 1 - Insists on scope resolution

// sit 2 - Insists on scope resolution
tPtrFunc fPtrFunc = A::func;
Jul 23 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.