RE: [Boost-users] Problems with call_traits in GCC 3.2 20020927(prerelease)

Joaquín Mª López Muñoz
The following programs does not compile with error
foo.cpp: In function `int main()': foo.cpp:11: no matching function for call to `foo(std::string)'
Program code:
#include
#include <string> template<typename Type> void foo(typename boost::call_traits<Type>::param_type x) { }
int main() { foo(std::string("bar"));
return 0; }
Environment is GCC 3.2 20020927 (prerelease) under Cygwin. Anyvody run into a similar problem? Workarounds, ideas? Thanx in advance.
This is standard behaviour. See my explanation in http://groups.google.com/groups?selm=slrnbisehj.1pc.do-not-spam-benh%40tin.b.... Without knowing what it is you are trying to do, I cannot offer a workaround.

Ben Hutchings ha escrito:
Joaquín Mª López Muñoz
wrote: The following programs does not compile with error
foo.cpp: In function `int main()': foo.cpp:11: no matching function for call to `foo(std::string)'
Program code:
#include
#include <string> template<typename Type> void foo(typename boost::call_traits<Type>::param_type x) { }
int main() { foo(std::string("bar"));
return 0; }
Environment is GCC 3.2 20020927 (prerelease) under Cygwin. Anyvody run into a similar problem? Workarounds, ideas? Thanx in advance.
This is standard behaviour. See my explanation in http://groups.google.com/groups?selm=slrnbisehj.1pc.do-not-spam-benh%40tin.b....
Thanks for the URL. Gotta look the section of the std you refer to.
Without knowing what it is you are trying to do, I cannot offer a workaround.
With pleasure. My original design was template<typename Type> void foo(const Type& x) { } (of course the actual code does something useful) and I wanted to take advantage of the call_traits<>::param_type optimization for basic types. So, no way? Should I revert to const Type&? Some clever workaround to help the compiler swallow the construct? Thx in advance. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

"Joaquín Mª López Muñoz"
The following programs does not compile with error
foo.cpp: In function `int main()': foo.cpp:11: no matching function for call to `foo(std::string)'
Program code:
#include
#include <string> template<typename Type> void foo(typename boost::call_traits<Type>::param_type x) { }
int main() { foo(std::string("bar"));
return 0; }
Compiler cannot deduce 'Type'. You have two options: 1. explicitly state type: foostd::string(std::string("bar")); 2. go to const& /Pavel
participants (3)
-
Ben Hutchings
-
Joaquín Mª López Muñoz
-
Pavel Vozenilek