C++0x: concept Convertible<T> issues
Hello!
I feed the following lines of code to the current GonceptG++ compiler
and was surprized that it didn't compile. It looks like
Convertible<int,T> doesn't cover implicit conversion which would allow
me using ints as parameters to a function that expects parameters of
type T.
----------8<----------
#include <iostream>
#include <concepts>
template<std::ArithmeticLike T>
T f(T a, T b) { return a + b; }
template<std::ArithmeticLike T> requires std::Convertible<int,T>
T g()
{
const int i1 = 1;
const int i2 = 2;
return f<T>(i1,i2); // Error! No implicit conversion int-->T
// Isn't this supposed to be covered by std::Convertible<int,T> ?
}
int main()
{
using std::cout;
using std::endl;
double x = f<double>(1,2); // OK
cout << x << endl;
}
----------8<----------
The error message I get is:
convert.cpp: In function ?T g()?:
convert.cpp:15: Fehler: keine passende Funktion f?r Aufruf
von ?f(const int&, const int&)?
(Translation: "Error: no suitable function for call ?f(const int&,
const int&)?")
Since the standard draft (N2677) clearly distinguishes between
Convertible
and ExplicitlyConvertible I expected the Convertible<int,T> concept to
cover implicit conversion from int to T.
Is this behavior expected or is it possibly a compiler/library bug?
Cheers,
SG
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]