Topic: compile time function exists check


Author: earonesty@gmail.com
Date: Mon, 2 Feb 2015 06:33:01 -0800 (PST)
Raw View
------=_Part_440_1892589861.1422887581144
Content-Type: multipart/alternative;
 boundary="----=_Part_441_230014463.1422887581144"

------=_Part_441_230014463.1422887581144
Content-Type: text/plain; charset=UTF-8

Has someone proposed something like this to alleviate the current spaghetti
of autoconf :

#ifndef(char *mkdtemp(char *))
    char *mkdtemp(char *) {
      ....
    }
#endif

I assume this has been proposed, but haven't been able to find it.

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_441_230014463.1422887581144
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Has someone proposed something like this to alleviate=
 the current spaghetti of autoconf :</div><div><br></div><div>#ifndef(char =
*mkdtemp(char *))</div><div>&nbsp; &nbsp; char *mkdtemp(char *) {</div><div=
>&nbsp; &nbsp; &nbsp; ....</div><div>&nbsp; &nbsp; }</div><div>#endif</div>=
<div><br></div><div>I assume this has been proposed, but haven't been able =
to find it.</div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_441_230014463.1422887581144--
------=_Part_440_1892589861.1422887581144--

.


Author: Jean-Marc Bourguet <jm.bourguet@gmail.com>
Date: Mon, 2 Feb 2015 06:38:19 -0800 (PST)
Raw View
------=_Part_2704_1943518871.1422887899409
Content-Type: multipart/alternative;
 boundary="----=_Part_2705_1495394027.1422887899409"

------=_Part_2705_1495394027.1422887899409
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Not that I know of.

It doesn't fit in the current compilation phases, so that doesn't seem easy=
=20
to define, nor to implement.

Yours,

Le lundi 2 f=C3=A9vrier 2015 15:33:01 UTC+1, earo...@gmail.com a =C3=A9crit=
 :
>
> Has someone proposed something like this to alleviate the current=20
> spaghetti of autoconf :
>
> #ifndef(char *mkdtemp(char *))
>     char *mkdtemp(char *) {
>       ....
>     }
> #endif
>
> I assume this has been proposed, but haven't been able to find it.
>

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

------=_Part_2705_1495394027.1422887899409
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Not that I know of.<div><br></div><div>It doesn't fit in t=
he current compilation phases, so that doesn't seem easy to define, nor to =
implement.<br><div><br></div><div>Yours,</div><div><br>Le lundi 2 f=C3=A9vr=
ier 2015 15:33:01 UTC+1, earo...@gmail.com a =C3=A9crit&nbsp;:<blockquote c=
lass=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px=
 #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>Has someone proposed =
something like this to alleviate the current spaghetti of autoconf :</div><=
div><br></div><div>#ifndef(char *mkdtemp(char *))</div><div>&nbsp; &nbsp; c=
har *mkdtemp(char *) {</div><div>&nbsp; &nbsp; &nbsp; ....</div><div>&nbsp;=
 &nbsp; }</div><div>#endif</div><div><br></div><div>I assume this has been =
proposed, but haven't been able to find it.</div></div></blockquote></div><=
/div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_2705_1495394027.1422887899409--
------=_Part_2704_1943518871.1422887899409--

.


Author: David Krauss <potswa@gmail.com>
Date: Tue, 3 Feb 2015 15:58:17 +0800
Raw View
--Apple-Mail=_289FA1EB-8778-4BB5-A3DE-677CADCD9EAF
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2015=E2=80=9302=E2=80=9302, at 10:33 PM, earonesty@gmail.com wrote:
>=20
> I assume this has been proposed, but haven't been able to find it.

Disabling function declarations is the purview of Concepts, so this might b=
e possible:

template< typename, typename =3D void > bool is_mkdtemp_defined =3D false;
template< typename t > bool is_mkdtemp_defined
    < t, decltype(void(mkdtemp( t{} ))) > =3D true;

char *mkdtemp( char * ) requires( ! is_mkdtemp_defined< char * > ) {

Templates can refer to undeclared function names. I=E2=80=99m not sure whet=
her requires clauses are allowed in non-template contexts, but such an exte=
nsion should be pretty straightforward.

If it=E2=80=99s OK for mkdtemp to be defined as a template (if you don=E2=
=80=99t need ABI compatibility with C code), then you can already do:

template< typename, typename =3D void >
struct is_mkdtemp_defined : std::false_type {};
template< typename t > struct is_mkdtemp_defined
    < t, decltype(void(mkdtemp( t{} ))) > : std::true_type {};

template< typename t =3D char *,
    typename =3D std::enable_if_t< ! is_mkdtemp_defined< t >::value > >
char * mkdtemp( char * ) {=20

Actually, this would still produce a C-compatible library if extern "C" wer=
e allowed in templates, but it=E2=80=99s not (=C2=A714/4).

See also http://stackoverflow.com/q/7313919/153285 . There=E2=80=99s also a=
 static_if proposal, but that medicine is worse than the disease.

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--Apple-Mail=_289FA1EB-8778-4BB5-A3DE-677CADCD9EAF
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9302=
=E2=80=9302, at 10:33 PM, <a href=3D"mailto:earonesty@gmail.com" class=3D""=
>earonesty@gmail.com</a> wrote:</div><br class=3D"Apple-interchange-newline=
"><div class=3D""><div dir=3D"ltr" class=3D""><div class=3D"">I assume this=
 has been proposed, but haven't been able to find it.</div></div></div></bl=
ockquote><div><br class=3D""></div><div>Disabling function declarations is =
the purview of Concepts, so this might be possible:</div><div><br class=3D"=
"></div><div><font face=3D"Courier" class=3D"">template&lt; typename, typen=
ame =3D void &gt; bool is_mkdtemp_defined =3D false;</font></div><div><font=
 face=3D"Courier" class=3D"">template&lt; typename t &gt; bool is_mkdtemp_d=
efined</font></div><div><span style=3D"font-family: Courier;" class=3D"">&n=
bsp; &nbsp; &lt; t, decltype(void(mkdtemp( t{} ))) &gt; =3D true;</span></d=
iv><div><span style=3D"font-family: Courier;" class=3D""><br class=3D""></s=
pan></div><div><span style=3D"font-family: Courier;" class=3D"">char *mkdte=
mp( char * ) requires( ! is_mkdtemp_defined&lt; char * &gt; ) {</span></div=
><div><span style=3D"font-family: Courier;" class=3D""><br class=3D""></spa=
n></div><div>Templates can refer to undeclared function names. I=E2=80=99m =
not sure whether requires clauses are allowed in non-template contexts, but=
 such an extension should be pretty straightforward.</div><div><br class=3D=
""></div><div>If it=E2=80=99s OK for <font face=3D"Courier" class=3D"">mkdt=
emp</font> to be defined as a template (if you don=E2=80=99t need ABI compa=
tibility with C code), then you can already do:</div><div><br class=3D""></=
div><font face=3D"Courier" class=3D"">template&lt; typename, typename =3D v=
oid &gt;</font></div><div><font face=3D"Courier" class=3D"">struct is_mkdte=
mp_defined : std::false_type {};<br class=3D"">template&lt; typename t &gt;=
 struct is_mkdtemp_defined<br class=3D"">&nbsp; &nbsp;&nbsp;&lt; t, decltyp=
e(void(mkdtemp( t{} ))) &gt; : std::true_type {};<br class=3D""><br class=
=3D""></font><div><font face=3D"Courier" class=3D"">template&lt; typename t=
 =3D char *,</font></div><div><font face=3D"Courier" class=3D"">&nbsp; &nbs=
p; typename =3D std::enable_if_t&lt; ! is_mkdtemp_defined&lt; t &gt;::value=
 &gt; &gt;</font></div><div><font face=3D"Courier" class=3D"">char * mkdtem=
p( char * ) {&nbsp;</font></div><div><br class=3D""></div><div>Actually, th=
is would still produce a C-compatible library if <font face=3D"Courier" cla=
ss=3D"">extern "C"</font> were allowed in templates, but it=E2=80=99s not (=
=C2=A714/4).</div><div><br class=3D""></div><div><div>See also&nbsp;<a href=
=3D"http://stackoverflow.com/q/7313919/153285" class=3D"">http://stackoverf=
low.com/q/7313919/153285</a> . There=E2=80=99s also a&nbsp;<font face=3D"Co=
urier" class=3D"">static_if</font>&nbsp;proposal, but that medicine is wors=
e than the disease.</div></div></div></body></html>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--Apple-Mail=_289FA1EB-8778-4BB5-A3DE-677CADCD9EAF--

.


Author: David Krauss <potswa@gmail.com>
Date: Tue, 3 Feb 2015 16:06:41 +0800
Raw View
--Apple-Mail=_2325ED33-816E-4C48-A06A-84F5D84AD8D1
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2015=E2=80=9302=E2=80=9303, at 3:58 PM, David Krauss <potswa@gmail.com=
> wrote:
>=20
> template< typename, typename =3D void >
> struct is_mkdtemp_defined : std::false_type {};
> template< typename t > struct is_mkdtemp_defined
>     < t, decltype(void(mkdtemp( t{} ))) > : std::true_type {};
>=20
> template< typename t =3D char *,
>     typename =3D std::enable_if_t< ! is_mkdtemp_defined< t >::value > >
> char * mkdtemp( char * ) {=20


Ehhh, this violates the ODR because the template definition changes meaning=
 between the first point of instantiation and the end of the source file. M=
ore future-proof solutions would use a namespace and a fallback overload as=
 in the linked StackOverflow page.

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--Apple-Mail=_2325ED33-816E-4C48-A06A-84F5D84AD8D1
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9302=
=E2=80=9303, at 3:58 PM, David Krauss &lt;<a href=3D"mailto:potswa@gmail.co=
m" class=3D"">potswa@gmail.com</a>&gt; wrote:</div><br class=3D"Apple-inter=
change-newline"><div class=3D""><div class=3D""><font face=3D"Courier" clas=
s=3D"">template&lt; typename, typename =3D void &gt;</font></div><div class=
=3D""><font face=3D"Courier" class=3D"" style=3D"font-size: 12px; font-styl=
e: normal; font-variant: normal; font-weight: normal; letter-spacing: norma=
l; line-height: normal; orphans: auto; text-align: start; text-indent: 0px;=
 text-transform: none; white-space: normal; widows: auto; word-spacing: 0px=
; -webkit-text-stroke-width: 0px;">struct is_mkdtemp_defined : std::false_t=
ype {};<br class=3D"">template&lt; typename t &gt; struct is_mkdtemp_define=
d<br class=3D"">&nbsp; &nbsp;&nbsp;&lt; t, decltype(void(mkdtemp( t{} ))) &=
gt; : std::true_type {};<br class=3D""><br class=3D""></font><div style=3D"=
font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: =
normal; font-weight: normal; letter-spacing: normal; line-height: normal; o=
rphans: auto; text-align: start; text-indent: 0px; text-transform: none; wh=
ite-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-wid=
th: 0px;" class=3D""><font face=3D"Courier" class=3D"">template&lt; typenam=
e t =3D char *,</font></div><div style=3D"font-family: Helvetica; font-size=
: 12px; font-style: normal; font-variant: normal; font-weight: normal; lett=
er-spacing: normal; line-height: normal; orphans: auto; text-align: start; =
text-indent: 0px; text-transform: none; white-space: normal; widows: auto; =
word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D""><font face=
=3D"Courier" class=3D"">&nbsp; &nbsp; typename =3D std::enable_if_t&lt; ! i=
s_mkdtemp_defined&lt; t &gt;::value &gt; &gt;</font></div><div style=3D"fon=
t-family: Helvetica; font-size: 12px; font-style: normal; font-variant: nor=
mal; font-weight: normal; letter-spacing: normal; line-height: normal; orph=
ans: auto; text-align: start; text-indent: 0px; text-transform: none; white=
-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width:=
 0px;" class=3D""><font face=3D"Courier" class=3D"">char * mkdtemp( char * =
) {&nbsp;</font></div></div></div></blockquote></div><div class=3D""><br cl=
ass=3D""></div><div class=3D"">Ehhh, this violates the ODR because the temp=
late definition changes meaning between the first point of instantiation an=
d the end of the source file. More future-proof solutions would use a names=
pace and a fallback overload as in the linked StackOverflow page.</div></bo=
dy></html>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--Apple-Mail=_2325ED33-816E-4C48-A06A-84F5D84AD8D1--

.


Author: Erik Aronesty <earonesty@gmail.com>
Date: Tue, 3 Feb 2015 08:55:17 -0500
Raw View
--001a113ce09abab2cd050e2f6b8b
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

It would certainly be a compile-time, not a precompiler time call.   At
compile-time it would not be very difficult, since compilers are *already
checking *for the existence of ambiguous symbols.

But you'd need some proper construct for it.

Probably the easiest way would be a reserved word, akin to the "throws"
construct.   No big change to the parse/lexer, easy to remember.

char * mkdtemp(char *) conditional {
      ....
}

This would be akin to the "weak" linker construct... but would be more
powerful and reliable, since the symbol would not even be exported.


Currently, all symbol declarations are "unconditional".   "Conditional
symbol declarations" is a fairly critical feature that would vastly
increase productivity when developing in C/C++

Again, though, it should probably be a C feature... not limited to C++.



On Mon, Feb 2, 2015 at 9:38 AM, Jean-Marc Bourguet <jm.bourguet@gmail.com>
wrote:

> Not that I know of.
>
> It doesn't fit in the current compilation phases, so that doesn't seem
> easy to define, nor to implement.
>
> Yours,
>
> Le lundi 2 f=C3=A9vrier 2015 15:33:01 UTC+1, earo...@gmail.com a =C3=A9cr=
it :
>>
>> Has someone proposed something like this to alleviate the current
>> spaghetti of autoconf :
>>
>> #ifndef(char *mkdtemp(char *))
>>     char *mkdtemp(char *) {
>>       ....
>>     }
>> #endif
>>
>> I assume this has been proposed, but haven't been able to find it.
>>
>

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--001a113ce09abab2cd050e2f6b8b
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">It would certainly be a compile-time, not a precompiler ti=
me call. =C2=A0 At compile-time it would not be very difficult, since compi=
lers are <i>already checking </i>for the existence of=C2=A0ambiguous=C2=A0s=
ymbols.<div><br></div><div>But you&#39;d need some proper construct for it.=
<div><br></div><div>Probably the easiest way would be a reserved word, akin=
 to the &quot;throws&quot; construct. =C2=A0 No big change to the parse/lex=
er, easy to remember.<br><div><br></div><div><span style=3D"font-size:12.80=
00001907349px">char * mkdtemp(char *) conditional {</span><br></div><div><d=
iv style=3D"font-size:12.8000001907349px">=C2=A0 =C2=A0 =C2=A0 ....</div><d=
iv style=3D"font-size:12.8000001907349px">}</div><div style=3D"font-size:12=
..8000001907349px"><br></div></div></div><div style=3D"font-size:12.80000019=
07349px">This would be akin to the &quot;weak&quot; linker construct... but=
 would be more powerful and reliable, since the symbol would not even be ex=
ported.</div><div style=3D"font-size:12.8000001907349px"><br></div><div sty=
le=3D"font-size:12.8000001907349px"><br></div><div style=3D"font-size:12.80=
00001907349px">Currently, all symbol declarations are &quot;unconditional&q=
uot;. =C2=A0 &quot;Conditional symbol declarations&quot; is a fairly critic=
al feature that would vastly increase productivity when developing in C/C++=
</div><div style=3D"font-size:12.8000001907349px"><br></div><div style=3D"f=
ont-size:12.8000001907349px">Again, though, it should probably be a C featu=
re... not limited to C++.</div><div style=3D"font-size:12.8000001907349px">=
<br></div><div style=3D"font-size:12.8000001907349px"><br></div></div></div=
><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Mon, Feb 2, 2=
015 at 9:38 AM, Jean-Marc Bourguet <span dir=3D"ltr">&lt;<a href=3D"mailto:=
jm.bourguet@gmail.com" target=3D"_blank">jm.bourguet@gmail.com</a>&gt;</spa=
n> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;b=
order-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Not that I kno=
w of.<div><br></div><div>It doesn&#39;t fit in the current compilation phas=
es, so that doesn&#39;t seem easy to define, nor to implement.<br><div><br>=
</div><div>Yours,</div><div><br>Le lundi 2 f=C3=A9vrier 2015 15:33:01 UTC+1=
, <a href=3D"mailto:earo...@gmail.com" target=3D"_blank">earo...@gmail.com<=
/a> a =C3=A9crit=C2=A0:<span class=3D""><blockquote class=3D"gmail_quote" s=
tyle=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:=
1ex"><div dir=3D"ltr"><div>Has someone proposed something like this to alle=
viate the current spaghetti of autoconf :</div><div><br></div><div>#ifndef(=
char *mkdtemp(char *))</div><div>=C2=A0 =C2=A0 char *mkdtemp(char *) {</div=
><div>=C2=A0 =C2=A0 =C2=A0 ....</div><div>=C2=A0 =C2=A0 }</div><div>#endif<=
/div><div><br></div><div>I assume this has been proposed, but haven&#39;t b=
een able to find it.</div></div></blockquote></span></div></div></div></blo=
ckquote></div><br></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--001a113ce09abab2cd050e2f6b8b--

.


Author: Erik Aronesty <earonesty@gmail.com>
Date: Tue, 3 Feb 2015 09:05:39 -0500
Raw View
--047d7b5d30d8cf161c050e2f9074
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

I would imagine that the only allowed conditions would be the existence or
non-existence of various symbols, classes, members, etc.   This would
enable the production of clean, cross-platform code.




On Tue, Feb 3, 2015 at 8:55 AM, Erik Aronesty <earonesty@gmail.com> wrote:

> It would certainly be a compile-time, not a precompiler time call.   At
> compile-time it would not be very difficult, since compilers are *already
> checking *for the existence of ambiguous symbols.
>
> But you'd need some proper construct for it.
>
> Probably the easiest way would be a reserved word, akin to the "throws"
> construct.   No big change to the parse/lexer, easy to remember.
>
> char * mkdtemp(char *) conditional {
>       ....
> }
>
> This would be akin to the "weak" linker construct... but would be more
> powerful and reliable, since the symbol would not even be exported.
>
>
> Currently, all symbol declarations are "unconditional".   "Conditional
> symbol declarations" is a fairly critical feature that would vastly
> increase productivity when developing in C/C++
>
> Again, though, it should probably be a C feature... not limited to C++.
>
>
>
> On Mon, Feb 2, 2015 at 9:38 AM, Jean-Marc Bourguet <jm.bourguet@gmail.com=
>
> wrote:
>
>> Not that I know of.
>>
>> It doesn't fit in the current compilation phases, so that doesn't seem
>> easy to define, nor to implement.
>>
>> Yours,
>>
>> Le lundi 2 f=C3=A9vrier 2015 15:33:01 UTC+1, earo...@gmail.com a =C3=A9c=
rit :
>>>
>>> Has someone proposed something like this to alleviate the current
>>> spaghetti of autoconf :
>>>
>>> #ifndef(char *mkdtemp(char *))
>>>     char *mkdtemp(char *) {
>>>       ....
>>>     }
>>> #endif
>>>
>>> I assume this has been proposed, but haven't been able to find it.
>>>
>>
>

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--047d7b5d30d8cf161c050e2f9074
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I would imagine that the only allowed conditions would be =
the existence or non-existence of various symbols, classes, members, etc. =
=C2=A0 This would enable the production of clean, cross-platform code.<div>=
<br></div><div><br></div><div><br></div></div><div class=3D"gmail_extra"><b=
r><div class=3D"gmail_quote">On Tue, Feb 3, 2015 at 8:55 AM, Erik Aronesty =
<span dir=3D"ltr">&lt;<a href=3D"mailto:earonesty@gmail.com" target=3D"_bla=
nk">earonesty@gmail.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail=
_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:=
1ex"><div dir=3D"ltr">It would certainly be a compile-time, not a precompil=
er time call. =C2=A0 At compile-time it would not be very difficult, since =
compilers are <i>already checking </i>for the existence of=C2=A0ambiguous=
=C2=A0symbols.<div><br></div><div>But you&#39;d need some proper construct =
for it.<div><br></div><div>Probably the easiest way would be a reserved wor=
d, akin to the &quot;throws&quot; construct. =C2=A0 No big change to the pa=
rse/lexer, easy to remember.<br><div><br></div><div><span style=3D"font-siz=
e:12.8000001907349px">char * mkdtemp(char *) conditional {</span><br></div>=
<div><div style=3D"font-size:12.8000001907349px">=C2=A0 =C2=A0 =C2=A0 ....<=
/div><div style=3D"font-size:12.8000001907349px">}</div><div style=3D"font-=
size:12.8000001907349px"><br></div></div></div><div style=3D"font-size:12.8=
000001907349px">This would be akin to the &quot;weak&quot; linker construct=
.... but would be more powerful and reliable, since the symbol would not eve=
n be exported.</div><div style=3D"font-size:12.8000001907349px"><br></div><=
div style=3D"font-size:12.8000001907349px"><br></div><div style=3D"font-siz=
e:12.8000001907349px">Currently, all symbol declarations are &quot;uncondit=
ional&quot;. =C2=A0 &quot;Conditional symbol declarations&quot; is a fairly=
 critical feature that would vastly increase productivity when developing i=
n C/C++</div><div style=3D"font-size:12.8000001907349px"><br></div><div sty=
le=3D"font-size:12.8000001907349px">Again, though, it should probably be a =
C feature... not limited to C++.</div><div style=3D"font-size:12.8000001907=
349px"><br></div><div style=3D"font-size:12.8000001907349px"><br></div></di=
v></div><div class=3D"HOEnZb"><div class=3D"h5"><div class=3D"gmail_extra">=
<br><div class=3D"gmail_quote">On Mon, Feb 2, 2015 at 9:38 AM, Jean-Marc Bo=
urguet <span dir=3D"ltr">&lt;<a href=3D"mailto:jm.bourguet@gmail.com" targe=
t=3D"_blank">jm.bourguet@gmail.com</a>&gt;</span> wrote:<br><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pa=
dding-left:1ex"><div dir=3D"ltr">Not that I know of.<div><br></div><div>It =
doesn&#39;t fit in the current compilation phases, so that doesn&#39;t seem=
 easy to define, nor to implement.<br><div><br></div><div>Yours,</div><div>=
<br>Le lundi 2 f=C3=A9vrier 2015 15:33:01 UTC+1, <a href=3D"mailto:earo...@=
gmail.com" target=3D"_blank">earo...@gmail.com</a> a =C3=A9crit=C2=A0:<span=
><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;bord=
er-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>Has someone =
proposed something like this to alleviate the current spaghetti of autoconf=
 :</div><div><br></div><div>#ifndef(char *mkdtemp(char *))</div><div>=C2=A0=
 =C2=A0 char *mkdtemp(char *) {</div><div>=C2=A0 =C2=A0 =C2=A0 ....</div><d=
iv>=C2=A0 =C2=A0 }</div><div>#endif</div><div><br></div><div>I assume this =
has been proposed, but haven&#39;t been able to find it.</div></div></block=
quote></span></div></div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--047d7b5d30d8cf161c050e2f9074--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Tue, 03 Feb 2015 11:16:20 -0800
Raw View
On Tuesday 03 February 2015 08:55:17 Erik Aronesty wrote:
> It would certainly be a compile-time, not a precompiler time call.   At
> compile-time it would not be very difficult, since compilers are *already
> checking *for the existence of ambiguous symbols.
>
> But you'd need some proper construct for it.
>
> Probably the easiest way would be a reserved word, akin to the "throws"
> construct.   No big change to the parse/lexer, easy to remember.
>
> char * mkdtemp(char *) conditional {
>       ....
> }
>
> This would be akin to the "weak" linker construct... but would be more
> powerful and reliable, since the symbol would not even be exported.
>
>
> Currently, all symbol declarations are "unconditional".   "Conditional
> symbol declarations" is a fairly critical feature that would vastly
> increase productivity when developing in C/C++
>
> Again, though, it should probably be a C feature... not limited to C++.

This exists in ELF and Mach-O and is supported by GCC, Clang and ICC.

For example, from Qt's Android support:

#ifdef Q_OS_ANDROID
// Android lacks pthread_condattr_setclock, but it does have a nice function
// for relative waits. Use weakref so we can determine at runtime whether it
is
// present.
static int local_cond_timedwait_relative(pthread_cond_t*, pthread_mutex_t *,
const timespec *)
__attribute__((weakref("__pthread_cond_timedwait_relative")));
#endif

[...]

#ifdef Q_OS_ANDROID
        if (Q_LIKELY(local_cond_timedwait_relative)) {
            ti.tv_sec = time / 1000;
            ti.tv_nsec = time % 1000 * Q_UINT64_C(1000) * 1000;
            return local_cond_timedwait_relative(&cond, &mutex, &ti);
        }
#endif
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: earonesty@gmail.com
Date: Wed, 11 Feb 2015 08:33:54 -0800 (PST)
Raw View
------=_Part_1190_895090150.1423672434896
Content-Type: multipart/alternative;
 boundary="----=_Part_1191_657203815.1423672434896"

------=_Part_1191_657203815.1423672434896
Content-Type: text/plain; charset=UTF-8

Yeah, just like weak ... but weak attributes are link-time, and are,
therefore inherently dangerous and won't be easy to make work with lots of
compilers.   And they're nonstandard, nonportable.

I really hate the idea that C++11 is coming out without a standard for
portability improvements.

Heck even standardizing on "weakref", as much as it is lacking, would be
far better than standardizing on nothing.


On Tuesday, February 3, 2015 at 2:17:35 PM UTC-5, Thiago Macieira wrote:
>
> On Tuesday 03 February 2015 08:55:17 Erik Aronesty wrote:
> > It would certainly be a compile-time, not a precompiler time call.   At
> > compile-time it would not be very difficult, since compilers are
> *already
> > checking *for the existence of ambiguous symbols.
> >
> > But you'd need some proper construct for it.
> >
> > Probably the easiest way would be a reserved word, akin to the "throws"
> > construct.   No big change to the parse/lexer, easy to remember.
> >
> > char * mkdtemp(char *) conditional {
> >       ....
> > }
> >
> > This would be akin to the "weak" linker construct... but would be more
> > powerful and reliable, since the symbol would not even be exported.
> >
> >
> > Currently, all symbol declarations are "unconditional".   "Conditional
> > symbol declarations" is a fairly critical feature that would vastly
> > increase productivity when developing in C/C++
> >
> > Again, though, it should probably be a C feature... not limited to C++.
>
> This exists in ELF and Mach-O and is supported by GCC, Clang and ICC.
>
> For example, from Qt's Android support:
>
> #ifdef Q_OS_ANDROID
> // Android lacks pthread_condattr_setclock, but it does have a nice
> function
> // for relative waits. Use weakref so we can determine at runtime whether
> it
> is
> // present.
> static int local_cond_timedwait_relative(pthread_cond_t*, pthread_mutex_t
> *,
> const timespec *)
> __attribute__((weakref("__pthread_cond_timedwait_relative")));
> #endif
>
> [...]
>
> #ifdef Q_OS_ANDROID
>         if (Q_LIKELY(local_cond_timedwait_relative)) {
>             ti.tv_sec = time / 1000;
>             ti.tv_nsec = time % 1000 * Q_UINT64_C(1000) * 1000;
>             return local_cond_timedwait_relative(&cond, &mutex, &ti);
>         }
> #endif
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
>    Software Architect - Intel Open Source Technology Center
>       PGP/GPG: 0x6EF45358; fingerprint:
>       E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
>
>

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_1191_657203815.1423672434896
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Yeah, just like weak ... but weak attributes are link-time=
, and are, therefore inherently dangerous and won't be easy to make work wi=
th lots of compilers. &nbsp; And they're nonstandard, nonportable.<div><br>=
</div><div>I really hate the idea that C++11 is coming out without a standa=
rd for portability improvements. &nbsp;</div><div><br></div><div>Heck even =
standardizing on "weakref", as much as it is lacking, would be far better t=
han standardizing on nothing.</div><div><br></div><div><br>On Tuesday, Febr=
uary 3, 2015 at 2:17:35 PM UTC-5, Thiago Macieira wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;">On Tuesday 03 February 2015 08:55:17 Erik Arone=
sty wrote:
<br>&gt; It would certainly be a compile-time, not a precompiler time call.=
 &nbsp; At
<br>&gt; compile-time it would not be very difficult, since compilers are *=
already
<br>&gt; checking *for the existence of ambiguous symbols.
<br>&gt;=20
<br>&gt; But you'd need some proper construct for it.
<br>&gt;=20
<br>&gt; Probably the easiest way would be a reserved word, akin to the "th=
rows"
<br>&gt; construct. &nbsp; No big change to the parse/lexer, easy to rememb=
er.
<br>&gt;=20
<br>&gt; char * mkdtemp(char *) conditional {
<br>&gt; &nbsp; &nbsp; &nbsp; ....
<br>&gt; }
<br>&gt;=20
<br>&gt; This would be akin to the "weak" linker construct... but would be =
more
<br>&gt; powerful and reliable, since the symbol would not even be exported=
..
<br>&gt;=20
<br>&gt;=20
<br>&gt; Currently, all symbol declarations are "unconditional". &nbsp; "Co=
nditional
<br>&gt; symbol declarations" is a fairly critical feature that would vastl=
y
<br>&gt; increase productivity when developing in C/C++
<br>&gt;=20
<br>&gt; Again, though, it should probably be a C feature... not limited to=
 C++.
<br>
<br>This exists in ELF and Mach-O and is supported by GCC, Clang and ICC.
<br>
<br>For example, from Qt's Android support:
<br>
<br>#ifdef Q_OS_ANDROID
<br>// Android lacks pthread_condattr_setclock, but it does have a nice fun=
ction
<br>// for relative waits. Use weakref so we can determine at runtime wheth=
er it=20
<br>is
<br>// present.
<br>static int local_cond_timedwait_relative(<wbr>pthread_cond_t*, pthread_=
mutex_t *,=20
<br>const timespec *)
<br>__attribute__((weakref("__<wbr>pthread_cond_timedwait_<wbr>relative")))=
;
<br>#endif
<br>
<br>[...]
<br>
<br>#ifdef Q_OS_ANDROID
<br>&nbsp; &nbsp; &nbsp; &nbsp; if (Q_LIKELY(local_cond_<wbr>timedwait_rela=
tive)) {
<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ti.tv_sec =3D time / 1000;
<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ti.tv_nsec =3D time % 1000 * =
Q_UINT64_C(1000) * 1000;
<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return local_cond_timedwait_r=
elative(<wbr>&amp;cond, &amp;mutex, &amp;ti);
<br>&nbsp; &nbsp; &nbsp; &nbsp; }
<br>#endif
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=
=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www.google.=
com/url?q\75http%3A%2F%2Fmacieira.info\46sa\75D\46sntz\0751\46usg\75AFQjCNE=
swDUBNCNanbu7euhqLn_62FW8ag';return true;" onclick=3D"this.href=3D'http://w=
ww.google.com/url?q\75http%3A%2F%2Fmacieira.info\46sa\75D\46sntz\0751\46usg=
\75AFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return true;">macieira.info</a> - th=
iago (AT) <a href=3D"http://kde.org" target=3D"_blank" rel=3D"nofollow" onm=
ousedown=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fkde.org=
\46sa\75D\46sntz\0751\46usg\75AFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA';return tr=
ue;" onclick=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fkde=
..org\46sa\75D\46sntz\0751\46usg\75AFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA';retur=
n true;">kde.org</a>
<br>&nbsp; &nbsp;Software Architect - Intel Open Source Technology Center
<br>&nbsp; &nbsp; &nbsp; PGP/GPG: 0x6EF45358; fingerprint:
<br>&nbsp; &nbsp; &nbsp; E067 918B B660 DBD1 105C &nbsp;966C 33F5 F005 6EF4=
 5358
<br>
<br></blockquote></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_1191_657203815.1423672434896--
------=_Part_1190_895090150.1423672434896--

.


Author: David Krauss <potswa@gmail.com>
Date: Thu, 12 Feb 2015 22:12:36 +0800
Raw View
--Apple-Mail=_733CB8C1-1168-439A-8D22-B65317B8CB66
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2015=E2=80=9302=E2=80=9312, at 12:33 AM, earonesty@gmail.com wrote:
>=20
> Yeah, just like weak ... but weak attributes are link-time, and are, ther=
efore inherently dangerous and won't be easy to make work with lots of comp=
ilers.   And they're nonstandard, nonportable.
>=20
> I really hate the idea that C++11 is coming out without a standard for po=
rtability improvements. =20
>=20
> Heck even standardizing on "weakref", as much as it is lacking, would be =
far better than standardizing on nothing.

Certain committee members are allergic to discussion of linkage, but it is =
a current practice, well within the ISO mandate of standardization.

Also, a basic form of weak linkage is already in the standard in the form o=
f replacement operator new. The case in this thread has replacement/weaknes=
s going the other way, but perhaps the concept of replacement could still b=
e adapted to apply.

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--Apple-Mail=_733CB8C1-1168-439A-8D22-B65317B8CB66
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9302=
=E2=80=9312, at 12:33 AM, <a href=3D"mailto:earonesty@gmail.com" class=3D""=
>earonesty@gmail.com</a> wrote:</div><br class=3D"Apple-interchange-newline=
"><div class=3D""><div dir=3D"ltr" class=3D"">Yeah, just like weak ... but =
weak attributes are link-time, and are, therefore inherently dangerous and =
won't be easy to make work with lots of compilers. &nbsp; And they're nonst=
andard, nonportable.<div class=3D""><br class=3D""></div><div class=3D"">I =
really hate the idea that C++11 is coming out without a standard for portab=
ility improvements. &nbsp;</div><div class=3D""><br class=3D""></div><div c=
lass=3D"">Heck even standardizing on "weakref", as much as it is lacking, w=
ould be far better than standardizing on nothing.</div></div></div></blockq=
uote><br class=3D""></div><div>Certain committee members are allergic to di=
scussion of linkage, but it is a current practice, well within the ISO mand=
ate of standardization.</div><div><br class=3D""></div><div>Also, a basic f=
orm of weak linkage is already in the standard in the form of replacement <=
font face=3D"Courier" class=3D"">operator new</font>. The case in this thre=
ad has replacement/weakness going the other way, but perhaps the concept of=
 replacement could still be adapted to apply.</div></body></html>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--Apple-Mail=_733CB8C1-1168-439A-8D22-B65317B8CB66--

.


Author: Zijie He <hzj_jie@hotmail.com>
Date: Thu, 12 Feb 2015 21:42:05 -0800 (PST)
Raw View
------=_Part_3195_1019775837.1423806125497
Content-Type: multipart/alternative;
 boundary="----=_Part_3196_305505752.1423806125497"

------=_Part_3196_305505752.1423806125497
Content-Type: text/plain; charset=UTF-8

Do I understand totally wrongly to the question? You want to have a
function, which will call another function if existing, otherwise provide a
new implementation.
Then the following code may help,
#pragma once
#include <type_traits>
#include "../utils/macro.hpp"

namespace __type_traits_private
{
    class Yes_t;
    class No_t;

    template <typename T>
    struct yes
    {
        const static bool value = (std::is_same<T, Yes_t&>::value) ||
                                  (std::is_same<T, Yes_t>::value);
    };

    template <typename T>
    struct no
    {
        const static bool value = (std::is_same<T, No_t&>::value) ||
                                  (std::is_same<T, No_t>::value);
    };
}

#ifdef __PRIVATE_HAS_DEF
    __PRIVATE_HAS_DEF redefined
#endif
#define __PRIVATE_HAS_DEF(name, TYPENAMES, BEGIN, type_check_typenames,
type_check_parameters) \
            template <TYPENAMES> \
            struct name { \
                BEGIN; \
                template <type_check_typenames> \
                struct type_check; \
                template <typename U> \
                static __type_traits_private::Yes_t&
test(type_check<type_check_parameters>*); \
                template <typename> \
                static __type_traits_private::No_t& test(...); \
                const static bool value =
__type_traits_private::yes<decltype(test<T>(nullptr))>::value; };

#ifdef HAS_TYPEDEF
    HAS_TYPEDEF redefined
#endif
#define HAS_TYPEDEF(typedef_name)
__PRIVATE_HAS_DEF(has_typedef_##typedef_name, \
                                                    typename T, \
                                                    , \
                                                    typename U, \
                                                    U::typedef_name);

#ifdef HAS_MEMBER_FUNCTION
    HAS_MEMBER_FUNCTION redefined
#endif
#define HAS_MEMBER_FUNCTION(func)
__PRIVATE_HAS_DEF(has_member_function_##func, \
                                                    typename T COMMA
typename RET_T COMMA typename... Args, \
                                                    typedef RET_T
(T::*Sign)(Args&&...), \
                                                    typename U COMMA U, \
                                                    Sign COMMA &U::func);

#ifdef HAS_CONST_MEMBER_FUNCTION
    HAS_CONST_MEMBER_FUNCTION redefined
#endif
#define HAS_CONST_MEMBER_FUNCTION(func)
__PRIVATE_HAS_DEF(has_const_member_function_##func, \
                                                          typename T COMMA
typename RET_T COMMA typename... Args, \
                                                          typedef RET_T
(T::*Sign)(Args&&...) const, \
                                                          typename U COMMA
U, \
                                                          Sign COMMA
&U::func);

It's pretty hard to understand, but you just need to use it in such way,
        struct copy_convert_to
    {
        template <typename T1, typename T2>
        static bool copy(const T1& i, T2& o)
        {
            return i.convert_to(o);
        }
    };

    struct copy_failure
    {
        template <typename T1, typename T2>
        static bool copy(const T1& i, T2& o)
        {
            return false;
        }
    };

    struct class_convertor
    {
    private:
        HAS_CONST_MEMBER_FUNCTION(convert_to);

    public:
        template <typename T1, typename T2>
        static bool copy(const T1& i, T2& o)
        {
            typedef typename std::conditional<
                                 has_const_member_function_convert_to<T1,
bool, T2&>::value,
                                 copy_convert_to,
                                 copy_failure
                             >::type
                             copy_type;
            return copy_type::copy(i, o);
        }
    };

But personally I do not like this implementation, it can only check a full
defined type before the line involved. Class declaration forward will break
the detection, since they are pretty compiling time logic.

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_3196_305505752.1423806125497
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Do I understand totally wrongly to the question? You want =
to have a function, which will call another function if existing, otherwise=
 provide a new implementation.<div><div>Then the following code may help,</=
div></div><div><div class=3D"prettyprint" style=3D"border: 1px solid rgb(18=
7, 187, 187); word-wrap: break-word; background-color: rgb(250, 250, 250);"=
><code class=3D"prettyprint"><div class=3D"subprettyprint"><div class=3D"su=
bprettyprint"><font color=3D"#660066">#pragma once</font></div><div class=
=3D"subprettyprint"><font color=3D"#660066">#include &lt;type_traits&gt;</f=
ont></div><div class=3D"subprettyprint"><font color=3D"#660066">#include ".=
../utils/macro.hpp"</font></div><div class=3D"subprettyprint"><font color=3D=
"#660066"><br></font></div><div class=3D"subprettyprint"><font color=3D"#66=
0066">namespace __type_traits_private</font></div><div class=3D"subprettypr=
int"><font color=3D"#660066">{</font></div><div class=3D"subprettyprint"><f=
ont color=3D"#660066">&nbsp; &nbsp; class Yes_t;</font></div><div class=3D"=
subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; class No_t;</font></d=
iv><div class=3D"subprettyprint"><font color=3D"#660066"><br></font></div><=
div class=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; template=
 &lt;typename T&gt;</font></div><div class=3D"subprettyprint"><font color=
=3D"#660066">&nbsp; &nbsp; struct yes</font></div><div class=3D"subprettypr=
int"><font color=3D"#660066">&nbsp; &nbsp; {</font></div><div class=3D"subp=
rettyprint"><font color=3D"#660066">&nbsp; &nbsp; &nbsp; &nbsp; const stati=
c bool value =3D (std::is_same&lt;T, Yes_t&amp;&gt;::value) ||</font></div>=
<div class=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp=
; &nbsp; &nbsp; &nbsp; (std::is_same&lt;T, Yes_t&gt;::value);</font></div><=
div class=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; };</font=
></div><div class=3D"subprettyprint"><font color=3D"#660066"><br></font></d=
iv><div class=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; temp=
late &lt;typename T&gt;</font></div><div class=3D"subprettyprint"><font col=
or=3D"#660066">&nbsp; &nbsp; struct no</font></div><div class=3D"subprettyp=
rint"><font color=3D"#660066">&nbsp; &nbsp; {</font></div><div class=3D"sub=
prettyprint"><font color=3D"#660066">&nbsp; &nbsp; &nbsp; &nbsp; const stat=
ic bool value =3D (std::is_same&lt;T, No_t&amp;&gt;::value) ||</font></div>=
<div class=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp=
; &nbsp; &nbsp; &nbsp; (std::is_same&lt;T, No_t&gt;::value);</font></div><d=
iv class=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; };</font>=
</div><div class=3D"subprettyprint"><font color=3D"#660066">}</font></div><=
div class=3D"subprettyprint"><font color=3D"#660066"><br></font></div><div =
class=3D"subprettyprint"><font color=3D"#660066">#ifdef __PRIVATE_HAS_DEF</=
font></div><div class=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nb=
sp; __PRIVATE_HAS_DEF redefined</font></div><div class=3D"subprettyprint"><=
font color=3D"#660066">#endif</font></div><div class=3D"subprettyprint"><fo=
nt color=3D"#660066">#define __PRIVATE_HAS_DEF(name, TYPENAMES, BEGIN, type=
_check_typenames, type_check_parameters) \</font></div><div class=3D"subpre=
ttyprint"><font color=3D"#660066">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=
 template &lt;TYPENAMES&gt; \</font></div><div class=3D"subprettyprint"><fo=
nt color=3D"#660066">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; struct name =
{ \</font></div><div class=3D"subprettyprint"><font color=3D"#660066">&nbsp=
; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BEGIN; \</font></div><di=
v class=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; &nbsp; &nb=
sp; &nbsp; &nbsp; &nbsp; &nbsp; template &lt;type_check_typenames&gt; \</fo=
nt></div><div class=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp=
; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; struct type_check; \</font></di=
v><div class=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; &nbsp=
; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; template &lt;typename U&gt; \</font></=
div><div class=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; &nb=
sp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; static __type_traits_private::Yes_t&=
amp; test(type_check&lt;type_check_parameters&gt;*); \</font></div><div cla=
ss=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; &nbsp; &nbsp; &=
nbsp; &nbsp; &nbsp; &nbsp; template &lt;typename&gt; \</font></div><div cla=
ss=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; &nbsp; &nbsp; &=
nbsp; &nbsp; &nbsp; &nbsp; static __type_traits_private::No_t&amp; test(...=
); \</font></div><div class=3D"subprettyprint"><font color=3D"#660066">&nbs=
p; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; const static bool value=
 =3D __type_traits_private::yes&lt;decltype(test&lt;T&gt;(nullptr))&gt;::va=
lue; };</font></div><div class=3D"subprettyprint"><font color=3D"#660066"><=
br></font></div><div class=3D"subprettyprint"><font color=3D"#660066">#ifde=
f HAS_TYPEDEF</font></div><div class=3D"subprettyprint"><font color=3D"#660=
066">&nbsp; &nbsp; HAS_TYPEDEF redefined</font></div><div class=3D"subprett=
yprint"><font color=3D"#660066">#endif</font></div><div class=3D"subprettyp=
rint"><font color=3D"#660066">#define HAS_TYPEDEF(typedef_name) __PRIVATE_H=
AS_DEF(has_typedef_##typedef_name, \</font></div><div class=3D"subprettypri=
nt"><font color=3D"#660066">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp=
; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nb=
sp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; typename T, \</=
font></div><div class=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nb=
sp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &=
nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=
 &nbsp; &nbsp; &nbsp; , \</font></div><div class=3D"subprettyprint"><font c=
olor=3D"#660066">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &n=
bsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; typename U, \</font></div>=
<div class=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp=
; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nb=
sp; &nbsp; U::typedef_name);</font></div><div class=3D"subprettyprint"><fon=
t color=3D"#660066"><br></font></div><div class=3D"subprettyprint"><font co=
lor=3D"#660066">#ifdef HAS_MEMBER_FUNCTION</font></div><div class=3D"subpre=
ttyprint"><font color=3D"#660066">&nbsp; &nbsp; HAS_MEMBER_FUNCTION redefin=
ed</font></div><div class=3D"subprettyprint"><font color=3D"#660066">#endif=
</font></div><div class=3D"subprettyprint"><font color=3D"#660066">#define =
HAS_MEMBER_FUNCTION(func) __PRIVATE_HAS_DEF(has_member_function_##func, \</=
font></div><div class=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nb=
sp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &=
nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=
 &nbsp; &nbsp; &nbsp; typename T COMMA typename RET_T COMMA typename... Arg=
s, \</font></div><div class=3D"subprettyprint"><font color=3D"#660066">&nbs=
p; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &n=
bsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; typedef RET_T (T::*Sign)(Args&amp;&amp;...), \<=
/font></div><div class=3D"subprettyprint"><font color=3D"#660066">&nbsp; &n=
bsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp=
; &nbsp; &nbsp; &nbsp; typename U COMMA U, \</font></div><div class=3D"subp=
rettyprint"><font color=3D"#660066">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbs=
p; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &n=
bsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sign CO=
MMA &amp;U::func);</font></div><div class=3D"subprettyprint"><font color=3D=
"#660066"><br></font></div><div class=3D"subprettyprint"><font color=3D"#66=
0066">#ifdef HAS_CONST_MEMBER_FUNCTION</font></div><div class=3D"subprettyp=
rint"><font color=3D"#660066">&nbsp; &nbsp; HAS_CONST_MEMBER_FUNCTION redef=
ined</font></div><div class=3D"subprettyprint"><font color=3D"#660066">#end=
if</font></div><div class=3D"subprettyprint"><font color=3D"#660066">#defin=
e HAS_CONST_MEMBER_FUNCTION(func) __PRIVATE_HAS_DEF(has_const_member_functi=
on_##func, \</font></div><div class=3D"subprettyprint"><font color=3D"#6600=
66">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &=
nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; typename T COMMA t=
ypename RET_T COMMA typename... Args, \</font></div><div class=3D"subpretty=
print"><font color=3D"#660066">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &n=
bsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp=
; &nbsp; typedef RET_T (T::*Sign)(Args&amp;&amp;...) const, \</font></div><=
div class=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; &nbsp; &=
nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbs=
p; &nbsp; &nbsp; &nbsp; &nbsp; typename U COMMA U, \</font></div><div class=
=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; &nbsp; &nbsp; &nb=
sp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &=
nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=
 &nbsp; &nbsp; &nbsp; Sign COMMA &amp;U::func);</font></div></div></code></=
div><div><br></div>It's pretty hard to understand, but you just need to use=
 it in such way,</div><div><div class=3D"prettyprint" style=3D"border: 1px =
solid rgb(187, 187, 187); word-wrap: break-word; background-color: rgb(250,=
 250, 250);"><code class=3D"prettyprint"><div class=3D"subprettyprint"><div=
 class=3D"subprettyprint"><span style=3D"color: rgb(102, 0, 102); font-fami=
ly: Arial, Helvetica, sans-serif;">&nbsp; &nbsp; &nbsp; &nbsp; struct copy_=
convert_to</span><br></div><div class=3D"subprettyprint"><font color=3D"#66=
0066">&nbsp; &nbsp; {</font></div><div class=3D"subprettyprint"><font color=
=3D"#660066">&nbsp; &nbsp; &nbsp; &nbsp; template &lt;typename T1, typename=
 T2&gt;</font></div><div class=3D"subprettyprint"><font color=3D"#660066">&=
nbsp; &nbsp; &nbsp; &nbsp; static bool copy(const T1&amp; i, T2&amp; o)</fo=
nt></div><div class=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp=
; &nbsp; &nbsp; {</font></div><div class=3D"subprettyprint"><font color=3D"=
#660066">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return i.convert_to(o);<=
/font></div><div class=3D"subprettyprint"><font color=3D"#660066">&nbsp; &n=
bsp; &nbsp; &nbsp; }</font></div><div class=3D"subprettyprint"><font color=
=3D"#660066">&nbsp; &nbsp; };</font></div><div class=3D"subprettyprint"><fo=
nt color=3D"#660066"><br></font></div><div class=3D"subprettyprint"><font c=
olor=3D"#660066">&nbsp; &nbsp; struct copy_failure</font></div><div class=
=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; {</font></div><di=
v class=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; &nbsp; &nb=
sp; template &lt;typename T1, typename T2&gt;</font></div><div class=3D"sub=
prettyprint"><font color=3D"#660066">&nbsp; &nbsp; &nbsp; &nbsp; static boo=
l copy(const T1&amp; i, T2&amp; o)</font></div><div class=3D"subprettyprint=
"><font color=3D"#660066">&nbsp; &nbsp; &nbsp; &nbsp; {</font></div><div cl=
ass=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; return false;</font></div><div class=3D"subprettyprint"><font=
 color=3D"#660066">&nbsp; &nbsp; &nbsp; &nbsp; }</font></div><div class=3D"=
subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; };</font></div><div c=
lass=3D"subprettyprint"><font color=3D"#660066"><br></font></div><div class=
=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; struct class_conv=
ertor</font></div><div class=3D"subprettyprint"><font color=3D"#660066">&nb=
sp; &nbsp; {</font></div><div class=3D"subprettyprint"><font color=3D"#6600=
66">&nbsp; &nbsp; private:</font></div><div class=3D"subprettyprint"><font =
color=3D"#660066">&nbsp; &nbsp; &nbsp; &nbsp; HAS_CONST_MEMBER_FUNCTION(con=
vert_to);</font></div><div class=3D"subprettyprint"><font color=3D"#660066"=
><br></font></div><div class=3D"subprettyprint"><font color=3D"#660066">&nb=
sp; &nbsp; public:</font></div><div class=3D"subprettyprint"><font color=3D=
"#660066">&nbsp; &nbsp; &nbsp; &nbsp; template &lt;typename T1, typename T2=
&gt;</font></div><div class=3D"subprettyprint"><font color=3D"#660066">&nbs=
p; &nbsp; &nbsp; &nbsp; static bool copy(const T1&amp; i, T2&amp; o)</font>=
</div><div class=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; &=
nbsp; &nbsp; {</font></div><div class=3D"subprettyprint"><font color=3D"#66=
0066">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; typedef typename std::condi=
tional&lt;</font></div><div class=3D"subprettyprint"><font color=3D"#660066=
">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nb=
sp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;has_const_member_function_conv=
ert_to&lt;T1, bool, T2&amp;&gt;::value,</font></div><div class=3D"subpretty=
print"><font color=3D"#660066">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &n=
bsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;c=
opy_convert_to,</font></div><div class=3D"subprettyprint"><font color=3D"#6=
60066">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp=
; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;copy_failure</font></div>=
<div class=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp=
; &nbsp;&gt;::type</font></div><div class=3D"subprettyprint"><font color=3D=
"#660066">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &n=
bsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;copy_type;</font></div><div class=3D=
"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=
 &nbsp; return copy_type::copy(i, o);</font></div><div class=3D"subprettypr=
int"><font color=3D"#660066">&nbsp; &nbsp; &nbsp; &nbsp; }</font></div><div=
 class=3D"subprettyprint"><font color=3D"#660066">&nbsp; &nbsp; };</font></=
div></div></code></div><br></div><div>But personally I do not like this imp=
lementation, it can only check a full defined type before the line involved=
.. Class declaration forward will break the detection, since they are pretty=
 compiling time logic.</div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_3196_305505752.1423806125497--
------=_Part_3195_1019775837.1423806125497--

.


Author: Erik Aronesty <erik@q32.com>
Date: Fri, 13 Feb 2015 11:20:35 -0500
Raw View
--001a11c29be8cceaa7050efa9d4d
Content-Type: text/plain; charset=UTF-8

It's a compile time issue, not a runtime issue, and the purpose is to set
standards for compile-time pragmas that enable portability.   Template
hacks are unreadable, and unlikely to be used/useful.

And it should work without templates, so you can provide definitions for
top level library functions.

The purpose is if an operating system doesn't provide a facility, like
mkdtemp, you can write a "conditional" function which is
*used only if not already defined.*
If you have ever looked at "portable" C++ code, you would realize, very
quickly, that this is an urgent, unmet need.

(( This is what "weak" was for... but "weak" isn't a standard, and it's a
link-time attribute, which, by definition, cannot be standardized.))

Another nice feature for portablility would be to standardizing
preprocessor include-guards IE: when including file X  you *always* get
some sort of INCLUDED_X defined or NOT_INCLUDED_X pre-defined for you.
Guessing names that change from library version to library version is
standard practice now, and it's horrible and the purpose of standards
bodies is to prevent this.  Or you can make a #ifinclude(<lib.h>) or
something.



On Fri, Feb 13, 2015 at 12:42 AM, Zijie He <hzj_jie@hotmail.com> wrote:

> Do I understand totally wrongly to the question? You want to have a
> function, which will call another function if existing, otherwise provide a
> new implementation.
> Then the following code may help,
> #pragma once
> #include <type_traits>
> #include "../utils/macro.hpp"
>
> namespace __type_traits_private
> {
>     class Yes_t;
>     class No_t;
>
>     template <typename T>
>     struct yes
>     {
>         const static bool value = (std::is_same<T, Yes_t&>::value) ||
>                                   (std::is_same<T, Yes_t>::value);
>     };
>
>     template <typename T>
>     struct no
>     {
>         const static bool value = (std::is_same<T, No_t&>::value) ||
>                                   (std::is_same<T, No_t>::value);
>     };
> }
>
> #ifdef __PRIVATE_HAS_DEF
>     __PRIVATE_HAS_DEF redefined
> #endif
> #define __PRIVATE_HAS_DEF(name, TYPENAMES, BEGIN, type_check_typenames,
> type_check_parameters) \
>             template <TYPENAMES> \
>             struct name { \
>                 BEGIN; \
>                 template <type_check_typenames> \
>                 struct type_check; \
>                 template <typename U> \
>                 static __type_traits_private::Yes_t&
> test(type_check<type_check_parameters>*); \
>                 template <typename> \
>                 static __type_traits_private::No_t& test(...); \
>                 const static bool value =
> __type_traits_private::yes<decltype(test<T>(nullptr))>::value; };
>
> #ifdef HAS_TYPEDEF
>     HAS_TYPEDEF redefined
> #endif
> #define HAS_TYPEDEF(typedef_name)
> __PRIVATE_HAS_DEF(has_typedef_##typedef_name, \
>                                                     typename T, \
>                                                     , \
>                                                     typename U, \
>                                                     U::typedef_name);
>
> #ifdef HAS_MEMBER_FUNCTION
>     HAS_MEMBER_FUNCTION redefined
> #endif
> #define HAS_MEMBER_FUNCTION(func)
> __PRIVATE_HAS_DEF(has_member_function_##func, \
>                                                     typename T COMMA
> typename RET_T COMMA typename... Args, \
>                                                     typedef RET_T
> (T::*Sign)(Args&&...), \
>                                                     typename U COMMA U, \
>                                                     Sign COMMA &U::func);
>
> #ifdef HAS_CONST_MEMBER_FUNCTION
>     HAS_CONST_MEMBER_FUNCTION redefined
> #endif
> #define HAS_CONST_MEMBER_FUNCTION(func)
> __PRIVATE_HAS_DEF(has_const_member_function_##func, \
>                                                           typename T COMMA
> typename RET_T COMMA typename... Args, \
>                                                           typedef RET_T
> (T::*Sign)(Args&&...) const, \
>                                                           typename U COMMA
> U, \
>                                                           Sign COMMA
> &U::func);
>
> It's pretty hard to understand, but you just need to use it in such way,
>         struct copy_convert_to
>     {
>         template <typename T1, typename T2>
>         static bool copy(const T1& i, T2& o)
>         {
>             return i.convert_to(o);
>         }
>     };
>
>     struct copy_failure
>     {
>         template <typename T1, typename T2>
>         static bool copy(const T1& i, T2& o)
>         {
>             return false;
>         }
>     };
>
>     struct class_convertor
>     {
>     private:
>         HAS_CONST_MEMBER_FUNCTION(convert_to);
>
>     public:
>         template <typename T1, typename T2>
>         static bool copy(const T1& i, T2& o)
>         {
>             typedef typename std::conditional<
>                                  has_const_member_function_convert_to<T1,
> bool, T2&>::value,
>                                  copy_convert_to,
>                                  copy_failure
>                              >::type
>                              copy_type;
>             return copy_type::copy(i, o);
>         }
>     };
>
> But personally I do not like this implementation, it can only check a full
> defined type before the line involved. Class declaration forward will break
> the detection, since they are pretty compiling time logic.
>
> --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/a/isocpp.org/d/topic/std-proposals/o9Jj23M3a3U/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

--001a11c29be8cceaa7050efa9d4d
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">It&#39;s a compile time issue, not a runtime issue, and th=
e purpose is to set standards for compile-time pragmas that enable portabil=
ity. =C2=A0 Template hacks are unreadable, and unlikely to be used/useful.<=
div><br><div>And it should work without templates, so you can provide defin=
itions for top level library functions.<br><br>The purpose is if an operati=
ng system doesn&#39;t provide a facility, like mkdtemp, you can write a &qu=
ot;conditional&quot; function which is <i>used only if not already defined.=
<br></i><br>If you have ever looked at &quot;portable&quot; C++ code, you w=
ould realize, very quickly, that this is an urgent, unmet need.</div><div><=
br>(( This is what &quot;weak&quot; was for... but &quot;weak&quot; isn&#39=
;t a standard, and it&#39;s a link-time attribute, which, by definition, ca=
nnot be standardized.))<br><br><div>Another nice feature for portablility w=
ould be to standardizing preprocessor include-guards IE: when including fil=
e X =C2=A0you *always* get some sort of INCLUDED_X defined or NOT_INCLUDED_=
X pre-defined for you. =C2=A0 Guessing names that change from library versi=
on to library version is standard practice now, and it&#39;s horrible and t=
he purpose of standards bodies is to prevent this.=C2=A0 Or you can make a =
#ifinclude(&lt;lib.h&gt;) or something.</div><div><br></div><div><br></div>=
</div></div></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote"=
>On Fri, Feb 13, 2015 at 12:42 AM, Zijie He <span dir=3D"ltr">&lt;<a href=
=3D"mailto:hzj_jie@hotmail.com" target=3D"_blank">hzj_jie@hotmail.com</a>&g=
t;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0=
 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Do I un=
derstand totally wrongly to the question? You want to have a function, whic=
h will call another function if existing, otherwise provide a new implement=
ation.<div><div>Then the following code may help,</div></div><div><div styl=
e=3D"border:1px solid rgb(187,187,187);word-wrap:break-word;background-colo=
r:rgb(250,250,250)"><code><div><div><font color=3D"#660066">#pragma once</f=
ont></div><div><font color=3D"#660066">#include &lt;type_traits&gt;</font><=
/div><div><font color=3D"#660066">#include &quot;../utils/macro.hpp&quot;</=
font></div><div><font color=3D"#660066"><br></font></div><div><font color=
=3D"#660066">namespace __type_traits_private</font></div><div><font color=
=3D"#660066">{</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 class=
 Yes_t;</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 class No_t;<=
/font></div><div><font color=3D"#660066"><br></font></div><div><font color=
=3D"#660066">=C2=A0 =C2=A0 template &lt;typename T&gt;</font></div><div><fo=
nt color=3D"#660066">=C2=A0 =C2=A0 struct yes</font></div><div><font color=
=3D"#660066">=C2=A0 =C2=A0 {</font></div><div><font color=3D"#660066">=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 const static bool value =3D (std::is_same&lt;T, Ye=
s_t&amp;&gt;::value) ||</font></div><div><font color=3D"#660066">=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (std::is_same&lt;T, Yes_t&gt;::value);</=
font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 };</font></div><div><=
font color=3D"#660066"><br></font></div><div><font color=3D"#660066">=C2=A0=
 =C2=A0 template &lt;typename T&gt;</font></div><div><font color=3D"#660066=
">=C2=A0 =C2=A0 struct no</font></div><div><font color=3D"#660066">=C2=A0 =
=C2=A0 {</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 const static bool value =3D (std::is_same&lt;T, No_t&amp;&gt;::value) |=
|</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 (std::is_same&lt;T, No_t&gt;::value);</font></div><div><font =
color=3D"#660066">=C2=A0 =C2=A0 };</font></div><div><font color=3D"#660066"=
>}</font></div><div><font color=3D"#660066"><br></font></div><div><font col=
or=3D"#660066">#ifdef __PRIVATE_HAS_DEF</font></div><div><font color=3D"#66=
0066">=C2=A0 =C2=A0 __PRIVATE_HAS_DEF redefined</font></div><div><font colo=
r=3D"#660066">#endif</font></div><div><font color=3D"#660066">#define __PRI=
VATE_HAS_DEF(name, TYPENAMES, BEGIN, type_check_typenames, type_check_param=
eters) \</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 template &lt;TYPENAMES&gt; \</font></div><div><font color=
=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 struct name { \</fon=
t></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 BEGIN; \</font></div><div><font color=3D"#660066">=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 template &lt;type_check_ty=
penames&gt; \</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 struct type_check; \</font></div><div><=
font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 template &lt;typename U&gt; \</font></div><div><font color=3D"#660066">=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 static __type_trait=
s_private::Yes_t&amp; test(type_check&lt;type_check_parameters&gt;*); \</fo=
nt></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 template &lt;typename&gt; \</font></div><div><font col=
or=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 stat=
ic __type_traits_private::No_t&amp; test(...); \</font></div><div><font col=
or=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cons=
t static bool value =3D __type_traits_private::yes&lt;decltype(test&lt;T&gt=
;(nullptr))&gt;::value; };</font></div><div><font color=3D"#660066"><br></f=
ont></div><div><font color=3D"#660066">#ifdef HAS_TYPEDEF</font></div><div>=
<font color=3D"#660066">=C2=A0 =C2=A0 HAS_TYPEDEF redefined</font></div><di=
v><font color=3D"#660066">#endif</font></div><div><font color=3D"#660066">#=
define HAS_TYPEDEF(typedef_name) __PRIVATE_HAS_DEF(has_typedef_##typedef_na=
me, \</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 typename T, \</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 , \</font></div><div><font color=3D"#660066">=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 typename U, \</font></div><div><font color=3D"#=
660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 U::typedef_name);</font></div><di=
v><font color=3D"#660066"><br></font></div><div><font color=3D"#660066">#if=
def HAS_MEMBER_FUNCTION</font></div><div><font color=3D"#660066">=C2=A0 =C2=
=A0 HAS_MEMBER_FUNCTION redefined</font></div><div><font color=3D"#660066">=
#endif</font></div><div><font color=3D"#660066">#define HAS_MEMBER_FUNCTION=
(func) __PRIVATE_HAS_DEF(has_member_function_##func, \</font></div><div><fo=
nt color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 typename T COMMA ty=
pename RET_T COMMA typename... Args, \</font></div><div><font color=3D"#660=
066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 typedef RET_T (T::*Sign)(Args&amp;&a=
mp;...), \</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 typename U COMMA U, \</font></div><div><font color=3D"#660066=
">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Sign COMMA &amp;U::func);</font></div><d=
iv><font color=3D"#660066"><br></font></div><div><font color=3D"#660066">#i=
fdef HAS_CONST_MEMBER_FUNCTION</font></div><div><font color=3D"#660066">=C2=
=A0 =C2=A0 HAS_CONST_MEMBER_FUNCTION redefined</font></div><div><font color=
=3D"#660066">#endif</font></div><div><font color=3D"#660066">#define HAS_CO=
NST_MEMBER_FUNCTION(func) __PRIVATE_HAS_DEF(has_const_member_function_##fun=
c, \</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 typename T COMMA typename RET_T COMMA typename.=
... Args, \</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 typedef RET_T (T::*Sign)(Args&amp;&amp;.=
...) const, \</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 typename U COMMA U, \</font></div><div><=
font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 Sign COMMA &amp;U::func);</font></div></div></code></div><div><br></div=
>It&#39;s pretty hard to understand, but you just need to use it in such wa=
y,</div><div><div style=3D"border:1px solid rgb(187,187,187);word-wrap:brea=
k-word;background-color:rgb(250,250,250)"><code><div><div><span style=3D"co=
lor:rgb(102,0,102);font-family:Arial,Helvetica,sans-serif">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 struct copy_convert_to</span><br></div><div><font color=3D"#6=
60066">=C2=A0 =C2=A0 {</font></div><div><font color=3D"#660066">=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 template &lt;typename T1, typename T2&gt;</font></div><di=
v><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 static bool copy(cons=
t T1&amp; i, T2&amp; o)</font></div><div><font color=3D"#660066">=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 {</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return i.convert_to(o);</font></div><div><font =
color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 }</font></div><div><font colo=
r=3D"#660066">=C2=A0 =C2=A0 };</font></div><div><font color=3D"#660066"><br=
></font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 struct copy_failur=
e</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 {</font></div><div=
><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 template &lt;typename =
T1, typename T2&gt;</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 static bool copy(const T1&amp; i, T2&amp; o)</font></div><div=
><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 {</font></div><div><fo=
nt color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return false=
;</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 }</f=
ont></div><div><font color=3D"#660066">=C2=A0 =C2=A0 };</font></div><div><f=
ont color=3D"#660066"><br></font></div><div><font color=3D"#660066">=C2=A0 =
=C2=A0 struct class_convertor</font></div><div><font color=3D"#660066">=C2=
=A0 =C2=A0 {</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 private=
:</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 HAS_=
CONST_MEMBER_FUNCTION(convert_to);</font></div><div><font color=3D"#660066"=
><br></font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 public:</font>=
</div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 template &lt=
;typename T1, typename T2&gt;</font></div><div><font color=3D"#660066">=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 static bool copy(const T1&amp; i, T2&amp; o)</font=
></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 {</font></d=
iv><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 t=
ypedef typename std::conditional&lt;</font></div><div><font color=3D"#66006=
6">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0has_const_member_function_c=
onvert_to&lt;T1, bool, T2&amp;&gt;::value,</font></div><div><font color=3D"=
#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0copy_convert_to,</font>=
</div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0copy_failure</font></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0&gt;::type</font></div><div><font color=3D"#660066">=C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0copy_type;</font></div><div><font color=3D"#660066"=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return copy_type::copy(i, o);</f=
ont></div><div><font color=3D"#660066">=C2=A0 =C2=A0 =C2=A0 =C2=A0 }</font>=
</div><div><font color=3D"#660066">=C2=A0 =C2=A0 };</font></div></div></cod=
e></div><br></div><div>But personally I do not like this implementation, it=
 can only check a full defined type before the line involved. Class declara=
tion forward will break the detection, since they are pretty compiling time=
 logic.</div></div><div class=3D"HOEnZb"><div class=3D"h5">

<p></p>

-- <br>
<br>
--- <br>
You received this message because you are subscribed to a topic in the Goog=
le Groups &quot;ISO C++ Standard - Future Proposals&quot; group.<br>
To unsubscribe from this topic, visit <a href=3D"https://groups.google.com/=
a/isocpp.org/d/topic/std-proposals/o9Jj23M3a3U/unsubscribe" target=3D"_blan=
k">https://groups.google.com/a/isocpp.org/d/topic/std-proposals/o9Jj23M3a3U=
/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href=
=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_blank">std-prop=
osals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--001a11c29be8cceaa7050efa9d4d--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Fri, 13 Feb 2015 09:52:51 -0800
Raw View
On Friday 13 February 2015 11:20:35 Erik Aronesty wrote:
> It's a compile time issue, not a runtime issue, and the purpose is to set
> standards for compile-time pragmas that enable portability.   Template
> hacks are unreadable, and unlikely to be used/useful.
>
> And it should work without templates, so you can provide definitions for
> top level library functions.
>
> The purpose is if an operating system doesn't provide a facility, like
> mkdtemp, you can write a "conditional" function which is
> *used only if not already defined.*
> If you have ever looked at "portable" C++ code, you would realize, very
> quickly, that this is an urgent, unmet need.

I totally agree.

I've managed to get away with some hacks, like for example for accept4:

namespace { namespace Supplement {
 int accept4(...) { errno = ENOSYS; return -1; }
} }

    fd = ::accept4(s, addr, static_cast<QT_SOCKLEN_T *>(addrlen), sockflags);
    if (fd != -1 || !(errno == ENOSYS || errno == EINVAL))
        return fd;
    // fall back

> (( This is what "weak" was for... but "weak" isn't a standard, and it's a
> link-time attribute, which, by definition, cannot be standardized.))

It depends on having C interfaces because you need to know the external name.
That would never work for C++ code.

> Another nice feature for portablility would be to standardizing
> preprocessor include-guards IE: when including file X  you *always* get
> some sort of INCLUDED_X defined or NOT_INCLUDED_X pre-defined for you.
> Guessing names that change from library version to library version is
> standard practice now, and it's horrible and the purpose of standards
> bodies is to prevent this.  Or you can make a #ifinclude(<lib.h>) or
> something.

I think we can use the SD-6 recommendation and make it a stronger requirement:

#if __has_include(<lib.h>)

For Qt, we decided that SD-6 is mandatory for C++14 features. When GCC 5 is
more widespread, we'll probably start relying on __has_include too for certain
features.

--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Zijie He <hzj_jie@hotmail.com>
Date: Mon, 2 Mar 2015 16:16:05 -0800 (PST)
Raw View
------=_Part_859_666451352.1425341765113
Content-Type: multipart/alternative;
 boundary="----=_Part_860_1604390856.1425341765118"

------=_Part_860_1604390856.1425341765118
Content-Type: text/plain; charset=UTF-8

I totally agree that, it will be better to have a compiler internal
functionality to check whether a function is existing during compiling. But
the template I have provided strictly follow the standard, and the same
magic uses widely in boost :)

On Saturday, February 14, 2015 at 1:52:55 AM UTC+8, Thiago Macieira wrote:
>
> On Friday 13 February 2015 11:20:35 Erik Aronesty wrote:
> > It's a compile time issue, not a runtime issue, and the purpose is to
> set
> > standards for compile-time pragmas that enable portability.   Template
> > hacks are unreadable, and unlikely to be used/useful.
> >
> > And it should work without templates, so you can provide definitions for
> > top level library functions.
> >
> > The purpose is if an operating system doesn't provide a facility, like
> > mkdtemp, you can write a "conditional" function which is
> > *used only if not already defined.*
> > If you have ever looked at "portable" C++ code, you would realize, very
> > quickly, that this is an urgent, unmet need.
>
> I totally agree.
>
> I've managed to get away with some hacks, like for example for accept4:
>
> namespace { namespace Supplement {
>         int accept4(...) { errno = ENOSYS; return -1; }
> } }
>
>     fd = ::accept4(s, addr, static_cast<QT_SOCKLEN_T *>(addrlen),
> sockflags);
>     if (fd != -1 || !(errno == ENOSYS || errno == EINVAL))
>         return fd;
>     // fall back
>
> > (( This is what "weak" was for... but "weak" isn't a standard, and it's
> a
> > link-time attribute, which, by definition, cannot be standardized.))
>
> It depends on having C interfaces because you need to know the external
> name.
> That would never work for C++ code.
>
> > Another nice feature for portablility would be to standardizing
> > preprocessor include-guards IE: when including file X  you *always* get
> > some sort of INCLUDED_X defined or NOT_INCLUDED_X pre-defined for you.
> > Guessing names that change from library version to library version is
> > standard practice now, and it's horrible and the purpose of standards
> > bodies is to prevent this.  Or you can make a #ifinclude(<lib.h>) or
> > something.
>
> I think we can use the SD-6 recommendation and make it a stronger
> requirement:
>
> #if __has_include(<lib.h>)
>
> For Qt, we decided that SD-6 is mandatory for C++14 features. When GCC 5
> is
> more widespread, we'll probably start relying on __has_include too for
> certain
> features.
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
>    Software Architect - Intel Open Source Technology Center
>       PGP/GPG: 0x6EF45358; fingerprint:
>       E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
>
>

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_860_1604390856.1425341765118
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I totally agree that, it will be better to have a compiler=
 internal functionality to check whether a function is existing during comp=
iling. But the template I have provided strictly follow the standard, and t=
he same magic uses widely in boost :)<br><br>On Saturday, February 14, 2015=
 at 1:52:55 AM UTC+8, Thiago Macieira wrote:<blockquote class=3D"gmail_quot=
e" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;paddin=
g-left: 1ex;">On Friday 13 February 2015 11:20:35 Erik Aronesty wrote:
<br>&gt; It's a compile time issue, not a runtime issue, and the purpose is=
 to set
<br>&gt; standards for compile-time pragmas that enable portability. &nbsp;=
 Template
<br>&gt; hacks are unreadable, and unlikely to be used/useful.
<br>&gt;=20
<br>&gt; And it should work without templates, so you can provide definitio=
ns for
<br>&gt; top level library functions.
<br>&gt;=20
<br>&gt; The purpose is if an operating system doesn't provide a facility, =
like
<br>&gt; mkdtemp, you can write a "conditional" function which is
<br>&gt; *used only if not already defined.*
<br>&gt; If you have ever looked at "portable" C++ code, you would realize,=
 very
<br>&gt; quickly, that this is an urgent, unmet need.
<br>
<br>I totally agree.
<br>
<br>I've managed to get away with some hacks, like for example for accept4:
<br>
<br>namespace { namespace Supplement {
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int accept4(...) { errn=
o =3D ENOSYS; return -1; }
<br>} }
<br>
<br>&nbsp; &nbsp; fd =3D ::accept4(s, addr, static_cast&lt;QT_SOCKLEN_T *&g=
t;(addrlen), sockflags);
<br>&nbsp; &nbsp; if (fd !=3D -1 || !(errno =3D=3D ENOSYS || errno =3D=3D E=
INVAL))
<br>&nbsp; &nbsp; &nbsp; &nbsp; return fd;
<br>&nbsp; &nbsp; // fall back
<br>
<br>&gt; (( This is what "weak" was for... but "weak" isn't a standard, and=
 it's a
<br>&gt; link-time attribute, which, by definition, cannot be standardized.=
))
<br>
<br>It depends on having C interfaces because you need to know the external=
 name.=20
<br>That would never work for C++ code.
<br>
<br>&gt; Another nice feature for portablility would be to standardizing
<br>&gt; preprocessor include-guards IE: when including file X &nbsp;you *a=
lways* get
<br>&gt; some sort of INCLUDED_X defined or NOT_INCLUDED_X pre-defined for =
you.
<br>&gt; Guessing names that change from library version to library version=
 is
<br>&gt; standard practice now, and it's horrible and the purpose of standa=
rds
<br>&gt; bodies is to prevent this. &nbsp;Or you can make a #ifinclude(&lt;=
lib.h&gt;) or
<br>&gt; something.
<br>
<br>I think we can use the SD-6 recommendation and make it a stronger requi=
rement:
<br>
<br>#if __has_include(&lt;lib.h&gt;)
<br>
<br>For Qt, we decided that SD-6 is mandatory for C++14 features. When GCC =
5 is=20
<br>more widespread, we'll probably start relying on __has_include too for =
certain=20
<br>features.
<br>
<br>--=20
<br>Thiago Macieira - thiago (AT) <a href=3D"http://macieira.info" target=
=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www.google.=
com/url?q\75http%3A%2F%2Fmacieira.info\46sa\75D\46sntz\0751\46usg\75AFQjCNE=
swDUBNCNanbu7euhqLn_62FW8ag';return true;" onclick=3D"this.href=3D'http://w=
ww.google.com/url?q\75http%3A%2F%2Fmacieira.info\46sa\75D\46sntz\0751\46usg=
\75AFQjCNEswDUBNCNanbu7euhqLn_62FW8ag';return true;">macieira.info</a> - th=
iago (AT) <a href=3D"http://kde.org" target=3D"_blank" rel=3D"nofollow" onm=
ousedown=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fkde.org=
\46sa\75D\46sntz\0751\46usg\75AFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA';return tr=
ue;" onclick=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fkde=
..org\46sa\75D\46sntz\0751\46usg\75AFQjCNHGRJdo5_JYG1DowztwAHAKs80XSA';retur=
n true;">kde.org</a>
<br>&nbsp; &nbsp;Software Architect - Intel Open Source Technology Center
<br>&nbsp; &nbsp; &nbsp; PGP/GPG: 0x6EF45358; fingerprint:
<br>&nbsp; &nbsp; &nbsp; E067 918B B660 DBD1 105C &nbsp;966C 33F5 F005 6EF4=
 5358
<br>
<br></blockquote></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_860_1604390856.1425341765118--
------=_Part_859_666451352.1425341765113--

.


Author: Jim Porter <jvp4846@g.rit.edu>
Date: Mon, 02 Mar 2015 18:48:14 -0600
Raw View
On 2/13/2015 10:20 AM, Erik Aronesty wrote:
> It's a compile time issue, not a runtime issue, and the purpose is to
> set standards for compile-time pragmas that enable portability.
> Template hacks are unreadable, and unlikely to be used/useful.
[snip]
> If you have ever looked at "portable" C++ code, you would realize, very
> quickly, that this is an urgent, unmet need.

I disagree rather strongly. I don't believe this is the responsibility
of a compiler, but rather the responsibility of a build configuration
system. While the preprocessor is very fast, it's even faster to do this
*before* compilation, i.e. during the "configure" step of your build.
This way, incremental builds don't even need to perform this check. Not
only that, this allows for more complex configuration tests such as
ensuring that the semantics of a function match your expectations (e.g.
the XSI vs GNU versions of strerror_r). Perhaps in this example, the
differing return type (int vs char*) would be enough for your proposal
to detect the semantic difference, but this doesn't necessarily apply
universally.

There are still other problems, such as Windows' tendency to prefix C
runtime functions with "_", e.g. _isatty(). This is semantically the
same as isatty(), and an intelligent configuration system could abstract
out this difference for you (e.g. by automatically providing an isatty()
shim on Windows in some project-specific namespace), but I don't see how
a standard language feature could be expected to do this, especially
given that POSIX isatty() and Windows _isatty() are found in different
headers (unistd.h vs io.h).

Even the proposed (and already-implemented) __has_include directive is
somewhat suspect. While it can be nice for simple things, like picking
between std::experimental::any and boost::any, this is again a
configuration-time issue, not a compile-time issue. Worse, it doesn't
actually ensure that boost::any matches your expected interface: Boost
1.54 and below don't have boost::any::clear(), whereas the Library
Extensions proposal (and Boost 1.55+) do. Besides that, the boilerplate
to check this is a bit excessive, and I think it would make more sense
as autogenerated code. At that point, you could just unconditionally
#include the appropriate header (and alias the appropriate namespace) in
a generated-at-config-time header file.

I agree of course that better cross-platform configuration tools should
exist for C++, but I don't think they belong in the language itself. The
build configuration system* is a better place.

- Jim

* e.g. autotools, CMake, etc. Granted, build config systems are usually
painful to use, but that's an argument for a better build config system,
not for incorporating these features into the compiler.

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.


Author: Jim Porter <jvp4846@g.rit.edu>
Date: Mon, 02 Mar 2015 18:56:11 -0600
Raw View
On 3/2/2015 6:48 PM, Jim Porter wrote:
> I disagree rather strongly. I don't believe this is the responsibility
> of a compiler, but rather the responsibility of a build configuration
> system. While the preprocessor is very fast, it's even faster to do this
> *before* compilation, i.e. during the "configure" step of your build.

Correction: this wouldn't happen in the preprocessing phase, but I
expect for many cases, it would still be fairly speedy.

In any case, I'd be happy to talk off-list about build configuration
systems, since I've been toying with some ideas about how they can be
improved.

- Jim

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

.