Re: Concepts and conversions
On 20 abr, 08:07, tasjae...@gmail.com wrote:
My question is, if a constrained function template uses Pootle as
follows:
template <Pootle P>
void g(P&& p) { f(p, X()); }
will this work with S as the template parameter? In particular, is a
double conversion performed (from X->Y->Z)?
For this piece of code:
// begin code
struct X { };
struct Y { Y(); Y(X); };
struct Z { Z(); Z(Y); };
struct S { };
void
f (S const&, Z);
template <typename T>
void
g (T const& t) { f(t, X()); }
void
h () { g(S()); }
//end code
Visual Studio 2005 gives me the error:
------ Build started: Project: tmp2, Configuration: Debug Win32 ------
Compiling...
test.cpp
c:\documents and settings\psilva\meus documentos\visual studio
2005\projects\remoting\tmp2\test.cpp(12) : error C2664: 'f' : cannot
convert parameter 2 from 'X' to 'Z'
No user-defined-conversion operator available that can perform
this conversion, or the operator cannot be called
c:\documents and settings\psilva\meus documentos\visual studio
2005\projects\remoting\tmp2\test.cpp(15) : see reference to function
template instantiation 'void g<S>(const T &)' being compiled
with
[
T=S
]
Build log was saved at "file://c:\Documents and Settings\psilva\Meus
documentos\Visual Studio 2005\Projects\Remoting\tmp2\Debug
\BuildLog.htm"
tmp2 - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
==========
I believe the reason is just that only one user-defined conversion is
allowed.
This rule should not be affected by the use of concept maps.
--
Pedro Lamar?o
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]