Topic: is_virtual_base_of<B, D> and has_virtual_base<T>


Author: Myriachan <myriachan@gmail.com>
Date: Thu, 25 Sep 2014 11:36:13 -0700 (PDT)
Raw View
------=_Part_1_735662937.1411670173888
Content-Type: text/plain; charset=UTF-8

It seems like these two are missing from type_traits: the ability to detect
that virtual inheritance is in use.


is_virtual_base_of<B, D> would be true_type if, when ignoring
cv-qualifiers, 1) B and D are non-union classes, 2) is_base_of<B, D>::value
!= false, and 3) there exists a class VD, which may equal D itself, for
which B is a direct virtual base class; otherwise, is_virtual_base_of<B, D>
would be false_type.  Note that unlike is_base_of, is_virtual_base_of is
not reflexive: is_virtual_base_of<X, X> is always false_type.

has_virtual_base<T> would be true_type if T is a non-union class and there
exists a B such that is_virtual_base_of<B, T>::value != false; otherwise
has_virtual_base<T> would be false_type.


has_virtual_base matches the naming style of has_virtual_destructor.


Another interesting one, but has far less use, would be:

template <typename T, typename R, typename... Args>
constexpr bool is_virtual_member_function(R (T::*mem_func_ptr)(Args...));

If it weren't for the constexpr, implementing that in GCC would actually be
pretty easy. =)

Melissa

--

---
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_1_735662937.1411670173888
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">It seems like these two are missing from type_traits: the =
ability to detect that virtual inheritance is in use.<br><br><br><span styl=
e=3D"font-family: courier new,monospace;">is_virtual_base_of&lt;B, D&gt;</s=
pan> would be <span style=3D"font-family: courier new,monospace;">true_type=
</span> if, when ignoring cv-qualifiers, 1) <span style=3D"font-family: cou=
rier new,monospace;">B</span> and <span style=3D"font-family: courier new,m=
onospace;">D</span> are non-union classes, 2) <span style=3D"font-family: c=
ourier new,monospace;">is_base_of&lt;B, D&gt;::value !=3D false</span>, and=
 3) there exists a class <span style=3D"font-family: courier new,monospace;=
">VD</span>, which may equal <span style=3D"font-family: courier new,monosp=
ace;">D</span> itself, for which <span style=3D"font-family: courier new,mo=
nospace;">B</span> is a direct virtual base class; otherwise, <span style=
=3D"font-family: courier new,monospace;">is_virtual_base_of&lt;B, D&gt;</sp=
an> would be <span style=3D"font-family: courier new,monospace;">false_type=
</span>.&nbsp; Note that unlike <span style=3D"font-family: courier new,mon=
ospace;">is_base_of</span>, <span style=3D"font-family: courier new,monospa=
ce;">is_virtual_base_of</span> is not reflexive: <span style=3D"font-family=
: courier new,monospace;">is_virtual_base_of&lt;X, X&gt;</span> is always <=
span style=3D"font-family: courier new,monospace;">false_type</span>.<br><b=
r><span style=3D"font-family: courier new,monospace;">has_virtual_base&lt;T=
&gt;</span> would be <span style=3D"font-family: courier new,monospace;">tr=
ue_type</span> if <span style=3D"font-family: courier new,monospace;">T</sp=
an> is a non-union class and there exists a <span style=3D"font-family: cou=
rier new,monospace;">B</span> such that <span style=3D"font-family: courier=
 new,monospace;">is_virtual_base_of&lt;B, T&gt;::value !=3D false</span>; o=
therwise <span style=3D"font-family: courier new,monospace;">has_virtual_ba=
se&lt;T&gt;</span> would be <span style=3D"font-family: courier new,monospa=
ce;">false_type</span>.<br><br><br><span style=3D"font-family: courier new,=
monospace;">has_virtual_base</span> matches the naming style of <span style=
=3D"font-family: courier new,monospace;">has_virtual_destructor</span>.<br>=
<br><br>Another interesting one, but has far less use, would be:<br><br><di=
v class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); bord=
er-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-=
wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint=
"><span style=3D"color: #008;" class=3D"styled-by-prettify">template</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">typename</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">typename</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> R</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">typename</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">...</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #606;" class=3D"styled-by-prettify">Args</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">constexpr</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">bool</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> is_virtual_member_function</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">R </span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::*</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">mem_func_ptr</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">)(</span><spa=
n style=3D"color: #606;" class=3D"styled-by-prettify">Args</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">...));</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br></span></div></code></div><=
br>If it weren't for the constexpr, implementing that in GCC would actually=
 be pretty easy. =3D)<br><br>Melissa</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_1_735662937.1411670173888--

.


Author: Cleiton Santoia <cleitonsantoia@gmail.com>
Date: Wed, 29 Oct 2014 14:52:13 -0700 (PDT)
Raw View
------=_Part_14_281748970.1414619533660
Content-Type: text/plain; charset=UTF-8


Hi, in N3987 we present some type traits, but we didn't attend to "has_virtual_base"
nor "has_virtual_destructor"...


Em quinta-feira, 25 de setembro de 2014 15h36min16s UTC-3, Myriachan
escreveu:
>
> It seems like these two are missing from type_traits: the ability to
> detect that virtual inheritance is in use.
>
>
> is_virtual_base_of<B, D> would be true_type if, when ignoring
> cv-qualifiers, 1) B and D are non-union classes, 2) is_base_of<B,
> D>::value != false, and 3) there exists a class VD, which may equal D
> itself, for which B is a direct virtual base class; otherwise, is_virtual_base_of<B,
> D> would be false_type.  Note that unlike is_base_of, is_virtual_base_of
> is not reflexive: is_virtual_base_of<X, X> is always false_type.
>
> has_virtual_base<T> would be true_type if T is a non-union class and
> there exists a B such that is_virtual_base_of<B, T>::value != false;
> otherwise has_virtual_base<T> would be false_type.
>
>
> has_virtual_base matches the naming style of has_virtual_destructor.
>
>
> Another interesting one, but has far less use, would be:
>
> template <typename T, typename R, typename... Args>
> constexpr bool is_virtual_member_function(R (T::*mem_func_ptr)(Args...));
>
> If it weren't for the constexpr, implementing that in GCC would actually
> be pretty easy. =)
>
> Melissa
>

--

---
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_14_281748970.1414619533660
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><br></div>Hi, in N3987 we present some type traits, b=
ut we didn't attend to "<span style=3D"font-family: 'courier new', monospac=
e;">has_virtual_base" nor "</span><span style=3D"font-family: 'courier new'=
, monospace;">has_virtual_destructor"...</span><div><font face=3D"courier n=
ew, monospace"><br></font><br>Em quinta-feira, 25 de setembro de 2014 15h36=
min16s UTC-3, Myriachan  escreveu:<blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;"><div dir=3D"ltr">It seems like these two are missing from type_traits=
: the ability to detect that virtual inheritance is in use.<br><br><br><spa=
n style=3D"font-family:courier new,monospace">is_virtual_base_of&lt;B, D&gt=
;</span> would be <span style=3D"font-family:courier new,monospace">true_ty=
pe</span> if, when ignoring cv-qualifiers, 1) <span style=3D"font-family:co=
urier new,monospace">B</span> and <span style=3D"font-family:courier new,mo=
nospace">D</span> are non-union classes, 2) <span style=3D"font-family:cour=
ier new,monospace">is_base_of&lt;B, D&gt;::value !=3D false</span>, and 3) =
there exists a class <span style=3D"font-family:courier new,monospace">VD</=
span>, which may equal <span style=3D"font-family:courier new,monospace">D<=
/span> itself, for which <span style=3D"font-family:courier new,monospace">=
B</span> is a direct virtual base class; otherwise, <span style=3D"font-fam=
ily:courier new,monospace">is_virtual_base_of&lt;B, D&gt;</span> would be <=
span style=3D"font-family:courier new,monospace">false_type</span>.&nbsp; N=
ote that unlike <span style=3D"font-family:courier new,monospace">is_base_o=
f</span>, <span style=3D"font-family:courier new,monospace">is_virtual_base=
_of</span> is not reflexive: <span style=3D"font-family:courier new,monospa=
ce">is_virtual_base_of&lt;X, X&gt;</span> is always <span style=3D"font-fam=
ily:courier new,monospace">false_type</span>.<br><br><span style=3D"font-fa=
mily:courier new,monospace">has_virtual_base&lt;T&gt;</span> would be <span=
 style=3D"font-family:courier new,monospace">true_type</span> if <span styl=
e=3D"font-family:courier new,monospace">T</span> is a non-union class and t=
here exists a <span style=3D"font-family:courier new,monospace">B</span> su=
ch that <span style=3D"font-family:courier new,monospace">is_virtual_base_o=
f&lt;B, T&gt;::value !=3D false</span>; otherwise <span style=3D"font-famil=
y:courier new,monospace">has_virtual_base&lt;T&gt;</span> would be <span st=
yle=3D"font-family:courier new,monospace">false_type</span>.<br><br><br><sp=
an style=3D"font-family:courier new,monospace">has_virtual_base</span> matc=
hes the naming style of <span style=3D"font-family:courier new,monospace">h=
as_virtual_destructor</span>.<br><br><br>Another interesting one, but has f=
ar less use, would be:<br><br><div style=3D"background-color:rgb(250,250,25=
0);border-color:rgb(187,187,187);border-style:solid;border-width:1px;word-w=
rap:break-word"><code><div><span style=3D"color:#008">template</span><span =
style=3D"color:#000"> </span><span style=3D"color:#660">&lt;</span><span st=
yle=3D"color:#008">typename</span><span style=3D"color:#000"> T</span><span=
 style=3D"color:#660">,</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#008">typename</span><span style=3D"color:#000"> R</span><span s=
tyle=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=
=3D"color:#008">typename</span><span style=3D"color:#660">...</span><span s=
tyle=3D"color:#000"> </span><span style=3D"color:#606">Args</span><span sty=
le=3D"color:#660">&gt;</span><span style=3D"color:#000"><br></span><span st=
yle=3D"color:#008">constexpr</span><span style=3D"color:#000"> </span><span=
 style=3D"color:#008">bool</span><span style=3D"color:#000"> is_virtual_mem=
ber_function</span><span style=3D"color:#660">(</span><span style=3D"color:=
#000">R </span><span style=3D"color:#660">(</span><span style=3D"color:#000=
">T</span><span style=3D"color:#660">::*</span><span style=3D"color:#000">m=
em_func_ptr</span><span style=3D"color:#660">)(</span><span style=3D"color:=
#606">Args</span><span style=3D"color:#660">...));</span><span style=3D"col=
or:#000"><br></span></div></code></div><br>If it weren't for the constexpr,=
 implementing that in GCC would actually be pretty easy. =3D)<br><br>Meliss=
a</div></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_14_281748970.1414619533660--

.