Basically, what I need is a set of templated functions with the first type parameter to be specified explicitly and the rest of type parameters as types for the function parameters.
The code at the end of the post compiled with g++ -ansi -pedantic compiles successfully in version 4.1.2, but fails in 3.4.6 with the following error: example.cc: In function `int main()': example.cc:12: error: call of overloaded `foo(const int&)' is ambiguous example.cc:3: note: candidates are: T foo(P&) [with T = int, P = const int] example.cc:7: note: T foo(const P&) [with T = int, P = int] It may seem that if it compiles in the new version, it was simply a bug fixed, but I found some discussion regarding similar problem, stating that the code is invalid in c++03 standard and that the c++0x standard will contain modifications allowing such construct to work. I really need the c++03 standard conformance, so my questions are: Is this code legal in the c++03 standard or not? Is there an alternate conforming way to achieve similar results? Thank you for any insight. template <typename T, typename P> T foo(P &p) { } template <typename T, typename P> T foo(const P &p) { } int main() { const int &x = 1; foo<int>(x); } _______________________________________________ help-gplusplus mailing list help-gplusplus@gnu.org http://lists.gnu.org/mailman/listinfo/help-gplusplus