Boost logo

Boost :

Subject: [boost] [conversion] ADL and templates
From: Vicente BOTET (vicente.botet_at_[hidden])
Date: 2011-05-30 16:51:47


I've tried to add a configuration point in Boost.Conversion via overloading and ADL, but while the internal call of the library can find them using a trick that adds a parameter that contains the type of the return type, the user is not able to find them without using the same this trick, but this is too dark to be natural for user code.

Next follows a simplified code of the problem. The following

namespace N {
struct S{};

template (*typename T*)
T fct1(S const& s) { return T(s); }
template (*typename T*)
void fct2(T &t, S const& s) { t=s; }

void test ()
N::S s1;
N::S s2;
fct2(s2, s1);
s2=fct1(*N::S*)(s1); // (1)

Results in a compile error in (1)

error: ‘fct1’ was not declared in this scope

Is it standard behavior that fct1 can not be found by ADL?


P.S. Please replace (* and *) by angle brackets.

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