Topic: Virtual static functions


Author: Myriachan <myriachan@gmail.com>
Date: Thu, 12 Nov 2015 12:50:01 -0800 (PST)
Raw View
------=_Part_6366_1819428397.1447361401736
Content-Type: multipart/alternative;
 boundary="----=_Part_6367_1734146880.1447361401737"

------=_Part_6367_1734146880.1447361401737
Content-Type: text/plain; charset=UTF-8

I've seen proposals for virtual static members, but what about functions?

class StorageBase
{
public:
    virtual ~StorageBase() { }
    virtual bool CanStoreValue(std::intmax_t value) const = 0;
};

template <typename T>
class StorageVector : public StorageBase
{
public:
    static_assert(std::is_arithmetic<T>::value && std::numeric_limits<T>::
is_signed);

    virtual static bool CanStoreValue(std::intmax_t value) const override
    {
        return (value >= std::numeric_limits<T>::min()) && (value <= std::
numeric_limits<T>::min());
    }

private:
    std::vector<T> m_vector;
};


The semantics would work pretty much as you'd expect with some details:

If a virtual static function is invoked on an object, either implicitly or
explicitly, it's a virtual call, unless class qualification is present.  If
invoked without an object, it's a static call.

Although semantically meaningless for the function itself because there is
no this, cv-qualifiers and ref-qualifiers would be required to match the
base virtual function in order to resolve among potential overloading on
these qualifiers.

&StorageVector::CanStoreValue would be of type bool
(StorageVector::*)(std::intmax_t).  StorageVector::CanStoreValue would be
of type bool (std::intmax_t) and implicitly become bool (*)(std::intmax_t)
like other static/non-member functions.

There are five approaches I can think of for an implementation to make this
work:

1. Emit code for the function twice, once for member and once for static.
2. Have the actual function be a static function, and generate a member
function that is a thunk to the static version as needed.
3. Have the actual function be a member function, and generate a static
function that is a thunk to the member version as needed (passing nullptr
as the this parameter, for example).
4. Have the actual function be a member function, and compile direct static
calls as the equivalent of e.g. ((StorageVector<T> *)
nullptr)->CanStoreValue(x).  Generate a static-to-member thunk if the
address of the static function is taken.
5. Have a single implementation, if the calling convention works.  (32-bit
x86 Windows with __stdcall could work in this manner, because the only
difference between __stdcall and __thiscall is that this is passed in ecx,
which a __stdcall function would ignore.)

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

<div dir=3D"ltr">I&#39;ve seen proposals for virtual static members, but wh=
at about functions?<br><br><div class=3D"prettyprint" style=3D"background-c=
olor: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: s=
olid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint=
"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"style=
d-by-prettify">class</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify"=
>StorageBase</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">public</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">virtual</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">~</span><span style=3D"color: #606;"=
 class=3D"styled-by-prettify">StorageBase</span><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: #660;" class=3D"style=
d-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =
=C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">vir=
tual</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #008;" class=3D"styled-by-prettify">bool</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">CanStoreValue</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">std</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">intmax_t value</span><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: #008;" class=3D"styled-b=
y-prettify">const</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">};</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">template</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">typename</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #606;" class=3D"styled-by-prettify">StorageVector</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">:</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">public</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by=
-prettify">StorageBase</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
></span><span style=3D"color: #008;" class=3D"styled-by-prettify">public</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">static_assert<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">std</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">is_arithmetic</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify">T</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">&gt;::</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">value </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">&amp;&amp;</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> std</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">numeric_limits</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">&lt;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">T</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;:=
:</span><span style=3D"color: #000;" class=3D"styled-by-prettify">is_signed=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br>=C2=A0 =C2=
=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify">virtua=
l</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">static</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">bool</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;" =
class=3D"styled-by-prettify">CanStoreValue</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">std</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify">intmax_t value</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">const=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">override</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>return</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">value </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">&gt;=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">numeric_limits</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">T</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&gt;::</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">min</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">())</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">&am=
p;&amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">value </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">&lt;=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">numeric_limits</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">T</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&gt;::</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">min</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">());</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">private</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=
=A0 =C2=A0 std</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">vect=
or</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">T</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> m_vector</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">};</span></div></code></div><br><br>The sem=
antics would work pretty much as you&#39;d expect with some details:<br><br=
>If a virtual static function is invoked on an object, either implicitly or=
 explicitly, it&#39;s a virtual call, unless class qualification is present=
..=C2=A0 If invoked without an object, it&#39;s a static call.<br><br>Althou=
gh semantically meaningless for the function itself because there is no <sp=
an style=3D"font-family: courier new,monospace;">this</span>, cv-qualifiers=
 and ref-qualifiers would be required to match the base virtual function in=
 order to resolve among potential overloading on these qualifiers.<br><br><=
span style=3D"font-family: courier new,monospace;">&amp;StorageVector::CanS=
toreValue</span> would be of type <span style=3D"font-family: courier new,m=
onospace;">bool (StorageVector::*)(std::intmax_t)</span>.=C2=A0 <span style=
=3D"font-family: courier new,monospace;">StorageVector::CanStoreValue</span=
> would be of type <span style=3D"font-family: courier new,monospace;">bool=
 (std::intmax_t)</span> and implicitly become <span style=3D"font-family: c=
ourier new,monospace;">bool (*)(std::intmax_t)</span> like other static/non=
-member functions.<br><br>There are five approaches I can think of for an i=
mplementation to make this work:<br><br>1. Emit code for the function twice=
, once for member and once for static.<br>2. Have the actual function be a =
static function, and generate a member function that is a thunk to the stat=
ic version as needed.<br>3. Have the actual function be a member function, =
and generate a static function that is a thunk to the member version as nee=
ded (passing <span style=3D"font-family: courier new,monospace;">nullptr</s=
pan> as the <span style=3D"font-family: courier new,monospace;">this</span>=
 parameter, for example).<br>4. Have the actual function be a member functi=
on, and compile direct static calls as the equivalent of e.g. <span style=
=3D"font-family: courier new,monospace;">((StorageVector&lt;T&gt; *) nullpt=
r)-&gt;CanStoreValue(x)</span>.=C2=A0 Generate a static-to-member thunk if =
the address of the static function is taken.<br>5. Have a single implementa=
tion, if the calling convention works.=C2=A0 (32-bit x86 Windows with <span=
 style=3D"font-family: courier new,monospace;">__stdcall</span> could work =
in this manner, because the only difference between <span style=3D"font-fam=
ily: courier new,monospace;">__stdcall</span> and <span style=3D"font-famil=
y: courier new,monospace;">__thiscall</span> is that <span style=3D"font-fa=
mily: courier new,monospace;">this</span> is passed in <span style=3D"font-=
family: courier new,monospace;">ecx</span>, which a <span style=3D"font-fam=
ily: courier new,monospace;">__stdcall</span> function would ignore.)<br><b=
r>Melissa<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 />

------=_Part_6367_1734146880.1447361401737--
------=_Part_6366_1819428397.1447361401736--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Thu, 12 Nov 2015 13:00:25 -0800
Raw View
On Thursday 12 November 2015 12:50:01 Myriachan wrote:
> 5. Have a single implementation, if the calling convention works.  (32-bit
> x86 Windows with __stdcall could work in this manner, because the only
> difference between __stdcall and __thiscall is that this is passed in ecx,
> which a __stdcall function would ignore.)

6. Have a single implementation that uses the regular calling convention used
for member functions, but for which the "this" pointer is ignored by caller
and callee. Caller passes any garbage and callee promises never to read it.

This allows the call from a base class using the virtual mechanism, which will
pass a valid this pointer.
--
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: Matthew Woehlke <mwoehlke.floss@gmail.com>
Date: Thu, 12 Nov 2015 16:14:06 -0500
Raw View
On 2015-11-12 15:50, Myriachan wrote:
> I've seen proposals for virtual static members, but what about functions?
>
> There are five approaches I can think of for an implementation to make this
> work:
>
> 1. Emit code for the function twice, once for member and once for static.
> 2. Have the actual function be a static function, and generate a member
> function that is a thunk to the static version as needed.
> 3. Have the actual function be a member function, and generate a static
> function that is a thunk to the member version as needed (passing nullptr
> as the this parameter, for example).
> 4. Have the actual function be a member function, and compile direct static
> calls as the equivalent of e.g. ((StorageVector<T> *)
> nullptr)->CanStoreValue(x).  Generate a static-to-member thunk if the
> address of the static function is taken.
> 5. Have a single implementation, if the calling convention works.  (32-bit
> x86 Windows with __stdcall could work in this manner, because the only
> difference between __stdcall and __thiscall is that this is passed in ecx,
> which a __stdcall function would ignore.)

I think you are overcomplicating things. The compiler knows if the
member is static or not (same as for a non-virtual member). The only
change is that a vtable look-up needs to occur. The obtained function
pointer can be called __stdcall as usual for a static member function.

So for a hypothetical machine with forth-like ABI:

  # static method call
  push <...args...>
  push &Object::member
  call

  # regular method call
  push <...args...>
  push <this> # __thiscall
  push &Object::member
  call

  # virtual method call
  push <...args...>
  push <this> # __thiscall
  push <this> # for vtable look-up
  push <member vtable offset>
  vtable_dereference
  call

  # virtual static method call
  push <...args...>
  push <this> # for vtable look-up
  push <member vtable offset>
  vtable_dereference
  call

(For a qualified virtual, obviously the three instructions to obtain the
member address would be replaced by pushing the address directly.)

Am I missing why this isn't possible?

--
Matthew

--

---
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: Myriachan <myriachan@gmail.com>
Date: Thu, 12 Nov 2015 15:42:07 -0800 (PST)
Raw View
------=_Part_12047_1639049956.1447371727168
Content-Type: multipart/alternative;
 boundary="----=_Part_12048_720338835.1447371727168"

------=_Part_12048_720338835.1447371727168
Content-Type: text/plain; charset=UTF-8

On Thursday, November 12, 2015 at 1:00:33 PM UTC-8, Thiago Macieira wrote:
>
> 6. Have a single implementation that uses the regular calling convention
> used
> for member functions, but for which the "this" pointer is ignored by
> caller
> and callee. Caller passes any garbage and callee promises never to read
> it.
>
> This allows the call from a base class using the virtual mechanism, which
> will
> pass a valid this pointer.
>

This is my #4.  Generating a thunk is still needed in this case if you take
the address of the static function, though.


On Thursday, November 12, 2015 at 1:14:16 PM UTC-8, Matthew Woehlke wrote:
>
> I think you are overcomplicating things. The compiler knows if the
> member is static or not (same as for a non-virtual member). The only
> change is that a vtable look-up needs to occur. The obtained function
> pointer can be called __stdcall as usual for a static member function.
>

It knows at the derived class level, but not at the base class level.
(Note in my example how the base class doesn't have static on the
function.)  This means that the vtable needs to point to a function that
accepts a non-static virtual call.

The converse situation comes into play if you take a pointer to the static
version of the function.  The user of the pointer of the function is going
to expect a non-member calling convention.

I suppose that I forgot to mention one thing: the way I see it, static on a
virtual function would not be inherited by overrides.  A non-static virtual
function could override a static virtual function and vice versa.


I'm more curious about what is thought about the feature in general, though
=^-^=

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

<div dir=3D"ltr">On Thursday, November 12, 2015 at 1:00:33 PM UTC-8, Thiago=
 Macieira wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">6. Have a sing=
le implementation that uses the regular calling convention used=20
<br>for member functions, but for which the &quot;this&quot; pointer is ign=
ored by caller=20
<br>and callee. Caller passes any garbage and callee promises never to read=
 it.
<br>
<br>This allows the call from a base class using the virtual mechanism, whi=
ch will=20
<br>pass a valid this pointer.
<br></blockquote><div><br>This is my #4.=C2=A0 Generating a thunk is still =
needed in this case if you take the address of the static function, though.=
<br></div><br><br>On Thursday, November 12, 2015 at 1:14:16 PM UTC-8, Matth=
ew Woehlke wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">I think you a=
re overcomplicating things. The compiler knows if the
<br>member is static or not (same as for a non-virtual member). The only
<br>change is that a vtable look-up needs to occur. The obtained function
<br>pointer can be called __stdcall as usual for a static member function.
<br></blockquote><div><br>It knows at the derived class level, but not at t=
he base class level.=C2=A0 (Note in my example how the base class doesn&#39=
;t have <span style=3D"font-family: courier new,monospace;">static</span> o=
n the function.)=C2=A0 This means that the vtable needs to point to a funct=
ion that accepts a non-static virtual call.<br><br>The converse situation c=
omes into play if you take a pointer to the static version of the function.=
=C2=A0 The user of the pointer of the function is going to expect a non-mem=
ber calling convention.<br><br>I suppose that I forgot to mention one thing=
: the way I see it, <span style=3D"font-family: courier new,monospace;">sta=
tic</span> on a virtual function would not be inherited by overrides.=C2=A0=
 A non-static virtual function could override a static virtual function and=
 vice versa.</div><br><br>I&#39;m more curious about what is thought about =
the feature in general, though =3D^-^=3D<br><br>Melissa<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 />

------=_Part_12048_720338835.1447371727168--
------=_Part_12047_1639049956.1447371727168--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Thu, 12 Nov 2015 16:20:18 -0800 (PST)
Raw View
------=_Part_10213_2119979280.1447374018913
Content-Type: multipart/alternative;
 boundary="----=_Part_10214_1575341806.1447374018913"

------=_Part_10214_1575341806.1447374018913
Content-Type: text/plain; charset=UTF-8

On Thursday, November 12, 2015 at 3:50:01 PM UTC-5, Myriachan wrote:
>
> I've seen proposals for virtual static members, but what about functions?
>

If I recall, the whole "virtual static data member" thing was just a way to
store an integer (technically other data too) into a particular class,
which could be initialized by derived classes, so that one could access a
derived class's value from a base class pointer/reference.

I have no idea how functions would fit into that paradigm.


> The semantics would work pretty much as you'd expect with some details:
>
> If a virtual static function is invoked on an object, either implicitly or
> explicitly, it's a virtual call, unless class qualification is present.  If
> invoked without an object, it's a static call.
>

Why would you need to do this? Why do you need a virtual function that
doesn't have a `this`? What problem does this solve?

--

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

<div dir=3D"ltr">On Thursday, November 12, 2015 at 3:50:01 PM UTC-5, Myriac=
han wrote:<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">I&#=
39;ve seen proposals for virtual static members, but what about functions?<=
br></div></blockquote><div><br>If I recall, the whole &quot;virtual static =
data member&quot; thing was just a way to store an integer (technically oth=
er data too) into a particular class, which could be initialized by derived=
 classes, so that one could access a derived class&#39;s value from a base =
class pointer/reference.<br><br>I have no idea how functions would fit into=
 that paradigm.<br>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"m=
argin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"=
><div dir=3D"ltr">The semantics would work pretty much as you&#39;d expect =
with some details:<br><br>If a virtual static function is invoked on an obj=
ect, either implicitly or explicitly, it&#39;s a virtual call, unless class=
 qualification is present.=C2=A0 If invoked without an object, it&#39;s a s=
tatic call.<br></div></blockquote><div><br>Why would you need to do this? W=
hy do you need a virtual function that doesn&#39;t have a `this`? What prob=
lem does this solve?</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 />

------=_Part_10214_1575341806.1447374018913--
------=_Part_10213_2119979280.1447374018913--

.


Author: Myriachan <myriachan@gmail.com>
Date: Thu, 12 Nov 2015 16:27:34 -0800 (PST)
Raw View
------=_Part_6467_1487180702.1447374454981
Content-Type: multipart/alternative;
 boundary="----=_Part_6468_152585819.1447374454981"

------=_Part_6468_152585819.1447374454981
Content-Type: text/plain; charset=UTF-8

On Thursday, November 12, 2015 at 4:20:19 PM UTC-8, Nicol Bolas wrote:
>
> On Thursday, November 12, 2015 at 3:50:01 PM UTC-5, Myriachan wrote:
>>
>> I've seen proposals for virtual static members, but what about functions?
>>
>
> If I recall, the whole "virtual static data member" thing was just a way
> to store an integer (technically other data too) into a particular class,
> which could be initialized by derived classes, so that one could access a
> derived class's value from a base class pointer/reference.
>
> I have no idea how functions would fit into that paradigm.
>

It's a way of having queries against either the class or an instance of the
class.


>
>
>> The semantics would work pretty much as you'd expect with some details:
>>
>> If a virtual static function is invoked on an object, either implicitly
>> or explicitly, it's a virtual call, unless class qualification is present.
>> If invoked without an object, it's a static call.
>>
>
> Why would you need to do this? Why do you need a virtual function that
> doesn't have a `this`? What problem does this solve?
>
>
It avoids having to create two copies of a function, one virtual and one
static.  In my example, I want to be able to query a polymorphic container
instance whether it accepts the integer I gave it.  I also want to be able
to ask the same question of a particular implementation, without needing to
create an instance.  static virtual functions avoid me needing two
functions to implement this.

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

<div dir=3D"ltr">On Thursday, November 12, 2015 at 4:20:19 PM UTC-8, Nicol =
Bolas wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">O=
n Thursday, November 12, 2015 at 3:50:01 PM UTC-5, Myriachan wrote:<blockqu=
ote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1=
px #ccc solid;padding-left:1ex"><div dir=3D"ltr">I&#39;ve seen proposals fo=
r virtual static members, but what about functions?<br></div></blockquote><=
div><br>If I recall, the whole &quot;virtual static data member&quot; thing=
 was just a way to store an integer (technically other data too) into a par=
ticular class, which could be initialized by derived classes, so that one c=
ould access a derived class&#39;s value from a base class pointer/reference=
..<br><br>I have no idea how functions would fit into that paradigm.<br></di=
v></div></blockquote><div><br>It&#39;s a way of having queries against eith=
er the class or an instance of the class.<br>=C2=A0</div><blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;"><div dir=3D"ltr"><div>=C2=A0</div><blockquote c=
lass=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #c=
cc solid;padding-left:1ex"><div dir=3D"ltr">The semantics would work pretty=
 much as you&#39;d expect with some details:<br><br>If a virtual static fun=
ction is invoked on an object, either implicitly or explicitly, it&#39;s a =
virtual call, unless class qualification is present.=C2=A0 If invoked witho=
ut an object, it&#39;s a static call.<br></div></blockquote><div><br>Why wo=
uld you need to do this? Why do you need a virtual function that doesn&#39;=
t have a `this`? What problem does this solve?</div><br></div></blockquote>=
<div><br>It avoids having to create two copies of a function, one virtual a=
nd one static.=C2=A0 In my example, I want to be able to query a polymorphi=
c container instance whether it accepts the integer I gave it.=C2=A0 I also=
 want to be able to ask the same question of a particular implementation, w=
ithout needing to create an instance.=C2=A0 static virtual functions avoid =
me needing two functions to implement this.<br><br>Melissa<br></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_6468_152585819.1447374454981--
------=_Part_6467_1487180702.1447374454981--

.


Author: Brent Friedman <fourthgeek@gmail.com>
Date: Thu, 12 Nov 2015 19:26:29 -0600
Raw View
--089e015374ecefea9c052461f2d8
Content-Type: text/plain; charset=UTF-8

I've had a desire for this from time to time (typically as a runtime
reflection factory mechanism). It might be hard to present a sufficiently
compelling argument to get this standardized, but I would like to see it.
The implementation and wording for this would seem to be relatively
straightforward as the semantics are pretty simple.

On Thu, Nov 12, 2015 at 6:27 PM, Myriachan <myriachan@gmail.com> wrote:

> On Thursday, November 12, 2015 at 4:20:19 PM UTC-8, Nicol Bolas wrote:
>>
>> On Thursday, November 12, 2015 at 3:50:01 PM UTC-5, Myriachan wrote:
>>>
>>> I've seen proposals for virtual static members, but what about functions?
>>>
>>
>> If I recall, the whole "virtual static data member" thing was just a way
>> to store an integer (technically other data too) into a particular class,
>> which could be initialized by derived classes, so that one could access a
>> derived class's value from a base class pointer/reference.
>>
>> I have no idea how functions would fit into that paradigm.
>>
>
> It's a way of having queries against either the class or an instance of
> the class.
>
>
>>
>>
>>> The semantics would work pretty much as you'd expect with some details:
>>>
>>> If a virtual static function is invoked on an object, either implicitly
>>> or explicitly, it's a virtual call, unless class qualification is present.
>>> If invoked without an object, it's a static call.
>>>
>>
>> Why would you need to do this? Why do you need a virtual function that
>> doesn't have a `this`? What problem does this solve?
>>
>>
> It avoids having to create two copies of a function, one virtual and one
> static.  In my example, I want to be able to query a polymorphic container
> instance whether it accepts the integer I gave it.  I also want to be able
> to ask the same question of a particular implementation, without needing to
> create an instance.  static virtual functions avoid me needing two
> functions to implement this.
>
> 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/.
>

--

---
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/.

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

<div dir=3D"ltr">I&#39;ve had a desire for this from time to time (typicall=
y as a runtime reflection factory mechanism). It might be hard to present a=
 sufficiently compelling argument to get this standardized, but I would lik=
e to see it. The implementation and wording for this would seem to be relat=
ively straightforward as the semantics are pretty simple.</div><div class=
=3D"gmail_extra"><br><div class=3D"gmail_quote">On Thu, Nov 12, 2015 at 6:2=
7 PM, Myriachan <span dir=3D"ltr">&lt;<a href=3D"mailto:myriachan@gmail.com=
" target=3D"_blank">myriachan@gmail.com</a>&gt;</span> wrote:<br><blockquot=
e class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc sol=
id;padding-left:1ex"><div dir=3D"ltr"><span class=3D"">On Thursday, Novembe=
r 12, 2015 at 4:20:19 PM UTC-8, Nicol Bolas wrote:<blockquote class=3D"gmai=
l_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;pad=
ding-left:1ex"><div dir=3D"ltr">On Thursday, November 12, 2015 at 3:50:01 P=
M UTC-5, Myriachan wrote:<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">I&#39;ve seen proposals for virtual static members, but what about=
 functions?<br></div></blockquote><div><br>If I recall, the whole &quot;vir=
tual static data member&quot; thing was just a way to store an integer (tec=
hnically other data too) into a particular class, which could be initialize=
d by derived classes, so that one could access a derived class&#39;s value =
from a base class pointer/reference.<br><br>I have no idea how functions wo=
uld fit into that paradigm.<br></div></div></blockquote></span><div><br>It&=
#39;s a way of having queries against either the class or an instance of th=
e class.<br>=C2=A0</div><span class=3D""><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"><div>=C2=A0</div><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">The semantics would work pretty much as you&#39;d exp=
ect with some details:<br><br>If a virtual static function is invoked on an=
 object, either implicitly or explicitly, it&#39;s a virtual call, unless c=
lass qualification is present.=C2=A0 If invoked without an object, it&#39;s=
 a static call.<br></div></blockquote><div><br>Why would you need to do thi=
s? Why do you need a virtual function that doesn&#39;t have a `this`? What =
problem does this solve?</div><br></div></blockquote></span><div><br>It avo=
ids having to create two copies of a function, one virtual and one static.=
=C2=A0 In my example, I want to be able to query a polymorphic container in=
stance whether it accepts the integer I gave it.=C2=A0 I also want to be ab=
le to ask the same question of a particular implementation, without needing=
 to create an instance.=C2=A0 static virtual functions avoid me needing two=
 functions to implement this.<br><br>Melissa<br></div></div><div class=3D"H=
OEnZb"><div class=3D"h5">

<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" target=3D"_=
blank">std-proposals+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 />

--089e015374ecefea9c052461f2d8--

.


Author: Richard Smith <richard@metafoo.co.uk>
Date: Thu, 12 Nov 2015 17:40:16 -0800
Raw View
--001a1140c11a3b96080524622400
Content-Type: text/plain; charset=UTF-8

On Thu, Nov 12, 2015 at 5:26 PM, Brent Friedman <fourthgeek@gmail.com>
wrote:

> I've had a desire for this from time to time (typically as a runtime
> reflection factory mechanism). It might be hard to present a sufficiently
> compelling argument to get this standardized, but I would like to see it.
> The implementation and wording for this would seem to be relatively
> straightforward as the semantics are pretty simple.
>

Given:

  struct X {
    virtual static f() { g(); }
    virtual static g();
  };
  struct Y : X {
    static g() override;
  };
  int main() { Y y; y.f(); }

.... which g() function would you expect to be called? There seem to be two
very different possibilities here, depending on whether you expect a
'virtual static' function to know/propagate the type for which it was
invoked.

On Thu, Nov 12, 2015 at 6:27 PM, Myriachan <myriachan@gmail.com> wrote:
>
>> On Thursday, November 12, 2015 at 4:20:19 PM UTC-8, Nicol Bolas wrote:
>>>
>>> On Thursday, November 12, 2015 at 3:50:01 PM UTC-5, Myriachan wrote:
>>>>
>>>> I've seen proposals for virtual static members, but what about
>>>> functions?
>>>>
>>>
>>> If I recall, the whole "virtual static data member" thing was just a way
>>> to store an integer (technically other data too) into a particular class,
>>> which could be initialized by derived classes, so that one could access a
>>> derived class's value from a base class pointer/reference.
>>>
>>> I have no idea how functions would fit into that paradigm.
>>>
>>
>> It's a way of having queries against either the class or an instance of
>> the class.
>>
>>
>>>
>>>
>>>> The semantics would work pretty much as you'd expect with some details:
>>>>
>>>> If a virtual static function is invoked on an object, either implicitly
>>>> or explicitly, it's a virtual call, unless class qualification is present.
>>>> If invoked without an object, it's a static call.
>>>>
>>>
>>> Why would you need to do this? Why do you need a virtual function that
>>> doesn't have a `this`? What problem does this solve?
>>>
>>>
>> It avoids having to create two copies of a function, one virtual and one
>> static.  In my example, I want to be able to query a polymorphic container
>> instance whether it accepts the integer I gave it.  I also want to be able
>> to ask the same question of a particular implementation, without needing to
>> create an instance.  static virtual functions avoid me needing two
>> functions to implement this.
>>
>> 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/.
>>
>
> --
>
> ---
> 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/.
>

--

---
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/.

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

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
hu, Nov 12, 2015 at 5:26 PM, Brent Friedman <span dir=3D"ltr">&lt;<a href=
=3D"mailto:fourthgeek@gmail.com" target=3D"_blank">fourthgeek@gmail.com</a>=
&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px=
 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);bor=
der-left-style:solid;padding-left:1ex"><div dir=3D"ltr">I&#39;ve had a desi=
re for this from time to time (typically as a runtime reflection factory me=
chanism). It might be hard to present a sufficiently compelling argument to=
 get this standardized, but I would like to see it. The implementation and =
wording for this would seem to be relatively straightforward as the semanti=
cs are pretty simple.</div></blockquote><div><br></div>Given:<div><br></div=
><div>=C2=A0 struct X {</div><div>=C2=A0 =C2=A0 virtual static f() { g(); }=
</div><div>=C2=A0 =C2=A0 virtual static g();</div><div>=C2=A0 };</div><div>=
=C2=A0 struct Y : X {</div><div>=C2=A0 =C2=A0 static g() override;</div><di=
v>=C2=A0 };</div><div>=C2=A0 int main() { Y y; y.f(); }<br><div class=3D"gm=
ail_extra"><br></div></div><div>... which g() function would you expect to =
be called? There seem to be two very different possibilities here, dependin=
g on whether you expect a &#39;virtual static&#39; function to know/propaga=
te the type for which it was invoked.</div><div><br></div><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;bo=
rder-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">=
<div class=3D""><div class=3D"h5"><div class=3D"gmail_extra"><div class=3D"=
gmail_quote">On Thu, Nov 12, 2015 at 6:27 PM, Myriachan <span dir=3D"ltr">&=
lt;<a href=3D"mailto:myriachan@gmail.com" target=3D"_blank">myriachan@gmail=
..com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"ma=
rgin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,=
204);border-left-style:solid;padding-left:1ex"><div dir=3D"ltr"><span>On Th=
ursday, November 12, 2015 at 4:20:19 PM UTC-8, Nicol Bolas wrote:<blockquot=
e class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width=
:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-lef=
t:1ex"><div dir=3D"ltr">On Thursday, November 12, 2015 at 3:50:01 PM UTC-5,=
 Myriachan wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px =
0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-l=
eft-style:solid;padding-left:1ex"><div dir=3D"ltr">I&#39;ve seen proposals =
for virtual static members, but what about functions?<br></div></blockquote=
><div><br>If I recall, the whole &quot;virtual static data member&quot; thi=
ng was just a way to store an integer (technically other data too) into a p=
articular class, which could be initialized by derived classes, so that one=
 could access a derived class&#39;s value from a base class pointer/referen=
ce.<br><br>I have no idea how functions would fit into that paradigm.<br></=
div></div></blockquote></span><div><br>It&#39;s a way of having queries aga=
inst either the class or an instance of the class.<br>=C2=A0</div><span><bl=
ockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-lef=
t-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padd=
ing-left:1ex"><div dir=3D"ltr"><div>=C2=A0</div><blockquote class=3D"gmail_=
quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-=
color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir=
=3D"ltr">The semantics would work pretty much as you&#39;d expect with some=
 details:<br><br>If a virtual static function is invoked on an object, eith=
er implicitly or explicitly, it&#39;s a virtual call, unless class qualific=
ation is present.=C2=A0 If invoked without an object, it&#39;s a static cal=
l.<br></div></blockquote><div><br>Why would you need to do this? Why do you=
 need a virtual function that doesn&#39;t have a `this`? What problem does =
this solve?</div><br></div></blockquote></span><div><br>It avoids having to=
 create two copies of a function, one virtual and one static.=C2=A0 In my e=
xample, I want to be able to query a polymorphic container instance whether=
 it accepts the integer I gave it.=C2=A0 I also want to be able to ask the =
same question of a particular implementation, without needing to create an =
instance.=C2=A0 static virtual functions avoid me needing two functions to =
implement this.<br><br>Melissa<br></div></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" target=3D"_=
blank">std-proposals+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" target=3D"_=
blank">std-proposals+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></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 />

--001a1140c11a3b96080524622400--

.


Author: Brent Friedman <fourthgeek@gmail.com>
Date: Thu, 12 Nov 2015 22:20:27 -0600
Raw View
--089e012950e61375240524646185
Content-Type: text/plain; charset=UTF-8

>
> Given:
>
>   struct X {
>     virtual static f() { g(); }
>     virtual static g();
>   };
>   struct Y : X {
>     static g() override;
>   };
>   int main() { Y y; y.f(); }
>
> ... which g() function would you expect to be called? There seem to be two
> very different possibilities here, depending on whether you expect a
> 'virtual static' function to know/propagate the type for which it was
> invoked.
>

My preference would be to invoke Y::g. However I realize this could be a
bit confusing. I'd also be OK with making this ill-formed and requiring
users to be explicit. Y::g() is OK and this->g() is OK but g() alone is
not. Then there's no confusion.



On Thu, Nov 12, 2015 at 7:40 PM, Richard Smith <richard@metafoo.co.uk>
wrote:

> On Thu, Nov 12, 2015 at 5:26 PM, Brent Friedman <fourthgeek@gmail.com>
> wrote:
>
>> I've had a desire for this from time to time (typically as a runtime
>> reflection factory mechanism). It might be hard to present a sufficiently
>> compelling argument to get this standardized, but I would like to see it.
>> The implementation and wording for this would seem to be relatively
>> straightforward as the semantics are pretty simple.
>>
>
> Given:
>
>   struct X {
>     virtual static f() { g(); }
>     virtual static g();
>   };
>   struct Y : X {
>     static g() override;
>   };
>   int main() { Y y; y.f(); }
>
> ... which g() function would you expect to be called? There seem to be two
> very different possibilities here, depending on whether you expect a
> 'virtual static' function to know/propagate the type for which it was
> invoked.
>
> On Thu, Nov 12, 2015 at 6:27 PM, Myriachan <myriachan@gmail.com> wrote:
>>
>>> On Thursday, November 12, 2015 at 4:20:19 PM UTC-8, Nicol Bolas wrote:
>>>>
>>>> On Thursday, November 12, 2015 at 3:50:01 PM UTC-5, Myriachan wrote:
>>>>>
>>>>> I've seen proposals for virtual static members, but what about
>>>>> functions?
>>>>>
>>>>
>>>> If I recall, the whole "virtual static data member" thing was just a
>>>> way to store an integer (technically other data too) into a particular
>>>> class, which could be initialized by derived classes, so that one could
>>>> access a derived class's value from a base class pointer/reference.
>>>>
>>>> I have no idea how functions would fit into that paradigm.
>>>>
>>>
>>> It's a way of having queries against either the class or an instance of
>>> the class.
>>>
>>>
>>>>
>>>>
>>>>> The semantics would work pretty much as you'd expect with some details:
>>>>>
>>>>> If a virtual static function is invoked on an object, either
>>>>> implicitly or explicitly, it's a virtual call, unless class qualification
>>>>> is present.  If invoked without an object, it's a static call.
>>>>>
>>>>
>>>> Why would you need to do this? Why do you need a virtual function that
>>>> doesn't have a `this`? What problem does this solve?
>>>>
>>>>
>>> It avoids having to create two copies of a function, one virtual and one
>>> static.  In my example, I want to be able to query a polymorphic container
>>> instance whether it accepts the integer I gave it.  I also want to be able
>>> to ask the same question of a particular implementation, without needing to
>>> create an instance.  static virtual functions avoid me needing two
>>> functions to implement this.
>>>
>>> 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/.
>>>
>>
>> --
>>
>> ---
>> 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/.
>>
>
> --
>
> ---
> 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/.
>

--

---
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/.

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

<div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px =
0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-l=
eft-style:solid;padding-left:1ex"><span style=3D"font-size:12.8px">Given:</=
span><div style=3D"font-size:12.8px"><br></div><div style=3D"font-size:12.8=
px">=C2=A0 struct X {</div><div style=3D"font-size:12.8px">=C2=A0 =C2=A0 vi=
rtual static f() { g(); }</div><div style=3D"font-size:12.8px">=C2=A0 =C2=
=A0 virtual static g();</div><div style=3D"font-size:12.8px">=C2=A0 };</div=
><div style=3D"font-size:12.8px">=C2=A0 struct Y : X {</div><div style=3D"f=
ont-size:12.8px">=C2=A0 =C2=A0 static g() override;</div><div style=3D"font=
-size:12.8px">=C2=A0 };</div><div style=3D"font-size:12.8px">=C2=A0 int mai=
n() { Y y; y.f(); }<br><div class=3D"gmail_extra"><br></div></div><div styl=
e=3D"font-size:12.8px">... which g() function would you expect to be called=
? There seem to be two very different possibilities here, depending on whet=
her you expect a &#39;virtual static&#39; function to know/propagate the ty=
pe for which it was invoked.</div></blockquote><div><br></div><div>My prefe=
rence would be to invoke Y::g. However I realize this could be a bit confus=
ing. I&#39;d also be OK with making this ill-formed and requiring users to =
be explicit. Y::g() is OK and this-&gt;g() is OK but g() alone is not. Then=
 there&#39;s no confusion.</div><div><br></div><div><br></div></div><div cl=
ass=3D"gmail_extra"><br><div class=3D"gmail_quote">On Thu, Nov 12, 2015 at =
7:40 PM, Richard Smith <span dir=3D"ltr">&lt;<a href=3D"mailto:richard@meta=
foo.co.uk" target=3D"_blank">richard@metafoo.co.uk</a>&gt;</span> wrote:<br=
><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1=
px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div class=3D"gmail_extra"=
><div class=3D"gmail_quote"><span class=3D"">On Thu, Nov 12, 2015 at 5:26 P=
M, Brent Friedman <span dir=3D"ltr">&lt;<a href=3D"mailto:fourthgeek@gmail.=
com" target=3D"_blank">fourthgeek@gmail.com</a>&gt;</span> wrote:<br><block=
quote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-w=
idth:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding=
-left:1ex"><div dir=3D"ltr">I&#39;ve had a desire for this from time to tim=
e (typically as a runtime reflection factory mechanism). It might be hard t=
o present a sufficiently compelling argument to get this standardized, but =
I would like to see it. The implementation and wording for this would seem =
to be relatively straightforward as the semantics are pretty simple.</div><=
/blockquote><div><br></div></span>Given:<div><br></div><div>=C2=A0 struct X=
 {</div><div>=C2=A0 =C2=A0 virtual static f() { g(); }</div><div>=C2=A0 =C2=
=A0 virtual static g();</div><div>=C2=A0 };</div><div>=C2=A0 struct Y : X {=
</div><div>=C2=A0 =C2=A0 static g() override;</div><div>=C2=A0 };</div><div=
>=C2=A0 int main() { Y y; y.f(); }<br><div class=3D"gmail_extra"><br></div>=
</div><div>... which g() function would you expect to be called? There seem=
 to be two very different possibilities here, depending on whether you expe=
ct a &#39;virtual static&#39; function to know/propagate the type for which=
 it was invoked.</div><div><div class=3D"h5"><div><br></div><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;=
border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex=
"><div><div><div class=3D"gmail_extra"><div class=3D"gmail_quote">On Thu, N=
ov 12, 2015 at 6:27 PM, Myriachan <span dir=3D"ltr">&lt;<a href=3D"mailto:m=
yriachan@gmail.com" target=3D"_blank">myriachan@gmail.com</a>&gt;</span> wr=
ote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex=
;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style=
:solid;padding-left:1ex"><div dir=3D"ltr"><span>On Thursday, November 12, 2=
015 at 4:20:19 PM UTC-8, Nicol Bolas wrote:<blockquote class=3D"gmail_quote=
" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color=
:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir=3D"ltr=
">On Thursday, November 12, 2015 at 3:50:01 PM UTC-5, Myriachan wrote:<bloc=
kquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-=
width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;paddin=
g-left:1ex"><div dir=3D"ltr">I&#39;ve seen proposals for virtual static mem=
bers, but what about functions?<br></div></blockquote><div><br>If I recall,=
 the whole &quot;virtual static data member&quot; thing was just a way to s=
tore an integer (technically other data too) into a particular class, which=
 could be initialized by derived classes, so that one could access a derive=
d class&#39;s value from a base class pointer/reference.<br><br>I have no i=
dea how functions would fit into that paradigm.<br></div></div></blockquote=
></span><div><br>It&#39;s a way of having queries against either the class =
or an instance of the class.<br>=C2=A0</div><span><blockquote class=3D"gmai=
l_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-lef=
t-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir=
=3D"ltr"><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin=
:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204)=
;border-left-style:solid;padding-left:1ex"><div dir=3D"ltr">The semantics w=
ould work pretty much as you&#39;d expect with some details:<br><br>If a vi=
rtual static function is invoked on an object, either implicitly or explici=
tly, it&#39;s a virtual call, unless class qualification is present.=C2=A0 =
If invoked without an object, it&#39;s a static call.<br></div></blockquote=
><div><br>Why would you need to do this? Why do you need a virtual function=
 that doesn&#39;t have a `this`? What problem does this solve?</div><br></d=
iv></blockquote></span><div><br>It avoids having to create two copies of a =
function, one virtual and one static.=C2=A0 In my example, I want to be abl=
e to query a polymorphic container instance whether it accepts the integer =
I gave it.=C2=A0 I also want to be able to ask the same question of a parti=
cular implementation, without needing to create an instance.=C2=A0 static v=
irtual functions avoid me needing two functions to implement this.<br><br>M=
elissa<br></div></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" target=3D"_=
blank">std-proposals+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" target=3D"_=
blank">std-proposals+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></div></div><br></div></div><div class=3D"HO=
EnZb"><div class=3D"h5">

<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" target=3D"_=
blank">std-proposals+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 />

--089e012950e61375240524646185--

.


Author: Brent Friedman <fourthgeek@gmail.com>
Date: Fri, 13 Nov 2015 08:01:29 -0600
Raw View
--047d7b33d2de011d9705246c7fa9
Content-Type: text/plain; charset=UTF-8

>
>  struct X {
>     virtual static f() { g(); }
>     virtual static g();
>   };
>

After thinking this over a bit more I think I better understand the
subtlety you are pointing out now.

Since f is virtual static, it has no 'this'. Therefore, it could only
possibly be X::g. So since this is a bit confusing, I'm leaning toward
ill-formed and requiring qualified ids or explicit member access syntax.

On Thu, Nov 12, 2015 at 10:20 PM, Brent Friedman <fourthgeek@gmail.com>
wrote:

> Given:
>>
>>   struct X {
>>     virtual static f() { g(); }
>>     virtual static g();
>>   };
>>   struct Y : X {
>>     static g() override;
>>   };
>>   int main() { Y y; y.f(); }
>>
>> ... which g() function would you expect to be called? There seem to be
>> two very different possibilities here, depending on whether you expect a
>> 'virtual static' function to know/propagate the type for which it was
>> invoked.
>>
>
> My preference would be to invoke Y::g. However I realize this could be a
> bit confusing. I'd also be OK with making this ill-formed and requiring
> users to be explicit. Y::g() is OK and this->g() is OK but g() alone is
> not. Then there's no confusion.
>
>
>
> On Thu, Nov 12, 2015 at 7:40 PM, Richard Smith <richard@metafoo.co.uk>
> wrote:
>
>> On Thu, Nov 12, 2015 at 5:26 PM, Brent Friedman <fourthgeek@gmail.com>
>> wrote:
>>
>>> I've had a desire for this from time to time (typically as a runtime
>>> reflection factory mechanism). It might be hard to present a sufficiently
>>> compelling argument to get this standardized, but I would like to see it.
>>> The implementation and wording for this would seem to be relatively
>>> straightforward as the semantics are pretty simple.
>>>
>>
>> Given:
>>
>>   struct X {
>>     virtual static f() { g(); }
>>     virtual static g();
>>   };
>>   struct Y : X {
>>     static g() override;
>>   };
>>   int main() { Y y; y.f(); }
>>
>> ... which g() function would you expect to be called? There seem to be
>> two very different possibilities here, depending on whether you expect a
>> 'virtual static' function to know/propagate the type for which it was
>> invoked.
>>
>> On Thu, Nov 12, 2015 at 6:27 PM, Myriachan <myriachan@gmail.com> wrote:
>>>
>>>> On Thursday, November 12, 2015 at 4:20:19 PM UTC-8, Nicol Bolas wrote:
>>>>>
>>>>> On Thursday, November 12, 2015 at 3:50:01 PM UTC-5, Myriachan wrote:
>>>>>>
>>>>>> I've seen proposals for virtual static members, but what about
>>>>>> functions?
>>>>>>
>>>>>
>>>>> If I recall, the whole "virtual static data member" thing was just a
>>>>> way to store an integer (technically other data too) into a particular
>>>>> class, which could be initialized by derived classes, so that one could
>>>>> access a derived class's value from a base class pointer/reference.
>>>>>
>>>>> I have no idea how functions would fit into that paradigm.
>>>>>
>>>>
>>>> It's a way of having queries against either the class or an instance of
>>>> the class.
>>>>
>>>>
>>>>>
>>>>>
>>>>>> The semantics would work pretty much as you'd expect with some
>>>>>> details:
>>>>>>
>>>>>> If a virtual static function is invoked on an object, either
>>>>>> implicitly or explicitly, it's a virtual call, unless class qualification
>>>>>> is present.  If invoked without an object, it's a static call.
>>>>>>
>>>>>
>>>>> Why would you need to do this? Why do you need a virtual function that
>>>>> doesn't have a `this`? What problem does this solve?
>>>>>
>>>>>
>>>> It avoids having to create two copies of a function, one virtual and
>>>> one static.  In my example, I want to be able to query a polymorphic
>>>> container instance whether it accepts the integer I gave it.  I also want
>>>> to be able to ask the same question of a particular implementation, without
>>>> needing to create an instance.  static virtual functions avoid me needing
>>>> two functions to implement this.
>>>>
>>>> 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/.
>>>>
>>>
>>> --
>>>
>>> ---
>>> 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/.
>>>
>>
>> --
>>
>> ---
>> 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/.
>>
>
>

--

---
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/.

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

<div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px =
0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-l=
eft-style:solid;padding-left:1ex"><div style=3D"font-size:12.8px">=C2=A0str=
uct X {</div><div style=3D"font-size:12.8px">=C2=A0 =C2=A0 virtual static f=
() { g(); }</div><div style=3D"font-size:12.8px">=C2=A0 =C2=A0 virtual stat=
ic g();</div><div style=3D"font-size:12.8px">=C2=A0 };</div></blockquote><d=
iv><br></div><div>After thinking this over a bit more I think I better unde=
rstand the subtlety you are pointing out now.</div><div><br></div><div>Sinc=
e f is virtual static, it has no &#39;this&#39;. Therefore, it could only p=
ossibly be X::g. So since this is a bit confusing, I&#39;m leaning toward i=
ll-formed and requiring qualified ids or explicit member access syntax.</di=
v></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Thu, N=
ov 12, 2015 at 10:20 PM, Brent Friedman <span dir=3D"ltr">&lt;<a href=3D"ma=
ilto:fourthgeek@gmail.com" target=3D"_blank">fourthgeek@gmail.com</a>&gt;</=
span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8e=
x;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span class=
=3D""><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;b=
order-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:s=
olid;padding-left:1ex"><span style=3D"font-size:12.8px">Given:</span><div s=
tyle=3D"font-size:12.8px"><br></div><div style=3D"font-size:12.8px">=C2=A0 =
struct X {</div><div style=3D"font-size:12.8px">=C2=A0 =C2=A0 virtual stati=
c f() { g(); }</div><div style=3D"font-size:12.8px">=C2=A0 =C2=A0 virtual s=
tatic g();</div><div style=3D"font-size:12.8px">=C2=A0 };</div><div style=
=3D"font-size:12.8px">=C2=A0 struct Y : X {</div><div style=3D"font-size:12=
..8px">=C2=A0 =C2=A0 static g() override;</div><div style=3D"font-size:12.8p=
x">=C2=A0 };</div><div style=3D"font-size:12.8px">=C2=A0 int main() { Y y; =
y.f(); }<br><div class=3D"gmail_extra"><br></div></div><div style=3D"font-s=
ize:12.8px">... which g() function would you expect to be called? There see=
m to be two very different possibilities here, depending on whether you exp=
ect a &#39;virtual static&#39; function to know/propagate the type for whic=
h it was invoked.</div></blockquote><div><br></div></span><div>My preferenc=
e would be to invoke Y::g. However I realize this could be a bit confusing.=
 I&#39;d also be OK with making this ill-formed and requiring users to be e=
xplicit. Y::g() is OK and this-&gt;g() is OK but g() alone is not. Then the=
re&#39;s no confusion.</div><div><br></div><div><br></div></div><div class=
=3D"HOEnZb"><div class=3D"h5"><div class=3D"gmail_extra"><br><div class=3D"=
gmail_quote">On Thu, Nov 12, 2015 at 7:40 PM, Richard Smith <span dir=3D"lt=
r">&lt;<a href=3D"mailto:richard@metafoo.co.uk" target=3D"_blank">richard@m=
etafoo.co.uk</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" sty=
le=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div d=
ir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote"><span>On T=
hu, Nov 12, 2015 at 5:26 PM, Brent Friedman <span dir=3D"ltr">&lt;<a href=
=3D"mailto:fourthgeek@gmail.com" target=3D"_blank">fourthgeek@gmail.com</a>=
&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px=
 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);bor=
der-left-style:solid;padding-left:1ex"><div dir=3D"ltr">I&#39;ve had a desi=
re for this from time to time (typically as a runtime reflection factory me=
chanism). It might be hard to present a sufficiently compelling argument to=
 get this standardized, but I would like to see it. The implementation and =
wording for this would seem to be relatively straightforward as the semanti=
cs are pretty simple.</div></blockquote><div><br></div></span>Given:<div><b=
r></div><div>=C2=A0 struct X {</div><div>=C2=A0 =C2=A0 virtual static f() {=
 g(); }</div><div>=C2=A0 =C2=A0 virtual static g();</div><div>=C2=A0 };</di=
v><div>=C2=A0 struct Y : X {</div><div>=C2=A0 =C2=A0 static g() override;</=
div><div>=C2=A0 };</div><div>=C2=A0 int main() { Y y; y.f(); }<br><div clas=
s=3D"gmail_extra"><br></div></div><div>... which g() function would you exp=
ect to be called? There seem to be two very different possibilities here, d=
epending on whether you expect a &#39;virtual static&#39; function to know/=
propagate the type for which it was invoked.</div><div><div><div><br></div>=
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;p=
adding-left:1ex"><div><div><div class=3D"gmail_extra"><div class=3D"gmail_q=
uote">On Thu, Nov 12, 2015 at 6:27 PM, Myriachan <span dir=3D"ltr">&lt;<a h=
ref=3D"mailto:myriachan@gmail.com" target=3D"_blank">myriachan@gmail.com</a=
>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0p=
x 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);bo=
rder-left-style:solid;padding-left:1ex"><div dir=3D"ltr"><span>On Thursday,=
 November 12, 2015 at 4:20:19 PM UTC-8, Nicol Bolas wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;bo=
rder-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">=
<div dir=3D"ltr">On Thursday, November 12, 2015 at 3:50:01 PM UTC-5, Myriac=
han wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8=
ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-sty=
le:solid;padding-left:1ex"><div dir=3D"ltr">I&#39;ve seen proposals for vir=
tual static members, but what about functions?<br></div></blockquote><div><=
br>If I recall, the whole &quot;virtual static data member&quot; thing was =
just a way to store an integer (technically other data too) into a particul=
ar class, which could be initialized by derived classes, so that one could =
access a derived class&#39;s value from a base class pointer/reference.<br>=
<br>I have no idea how functions would fit into that paradigm.<br></div></d=
iv></blockquote></span><div><br>It&#39;s a way of having queries against ei=
ther the class or an instance of the class.<br>=C2=A0</div><span><blockquot=
e class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width=
:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-lef=
t:1ex"><div dir=3D"ltr"><div>=C2=A0</div><blockquote class=3D"gmail_quote" =
style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:r=
gb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir=3D"ltr">=
The semantics would work pretty much as you&#39;d expect with some details:=
<br><br>If a virtual static function is invoked on an object, either implic=
itly or explicitly, it&#39;s a virtual call, unless class qualification is =
present.=C2=A0 If invoked without an object, it&#39;s a static call.<br></d=
iv></blockquote><div><br>Why would you need to do this? Why do you need a v=
irtual function that doesn&#39;t have a `this`? What problem does this solv=
e?</div><br></div></blockquote></span><div><br>It avoids having to create t=
wo copies of a function, one virtual and one static.=C2=A0 In my example, I=
 want to be able to query a polymorphic container instance whether it accep=
ts the integer I gave it.=C2=A0 I also want to be able to ask the same ques=
tion of a particular implementation, without needing to create an instance.=
=C2=A0 static virtual functions avoid me needing two functions to implement=
 this.<br><br>Melissa<br></div></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" target=3D"_=
blank">std-proposals+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" target=3D"_=
blank">std-proposals+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></div></div><br></div></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" target=3D"_=
blank">std-proposals+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>
</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 />

--047d7b33d2de011d9705246c7fa9--

.


Author: Miro Knejp <miro.knejp@gmail.com>
Date: Fri, 13 Nov 2015 17:32:43 -0800 (PST)
Raw View
------=_Part_5_1312308030.1447464763313
Content-Type: multipart/alternative;
 boundary="----=_Part_6_160759906.1447464763313"

------=_Part_6_160759906.1447464763313
Content-Type: text/plain; charset=UTF-8

On Friday, November 13, 2015 at 3:01:34 PM UTC+1, Brent Friedman wrote:
>
>  struct X {
>>     virtual static f() { g(); }
>>     virtual static g();
>>   };
>>
>
> After thinking this over a bit more I think I better understand the
> subtlety you are pointing out now.
>
> Since f is virtual static, it has no 'this'. Therefore, it could only
> possibly be X::g. So since this is a bit confusing, I'm leaning toward
> ill-formed and requiring qualified ids or explicit member access syntax.
>
This can be fixed by giving it a replacement. Member functions get "this"
 and thus implicitly know where to find their dynamic vtable.
For a static virtual function it would be sufficient to pass it the "static
vtable" pointer, i.e. a dynamic vtable containing only the virtual *static*
functions.
But that breaks as soon as it calls a non-virtual static function, as that
vtable pointer is then lost if it isn't also passed to non-virtual static
methods.
But that is a severe ABI break.

To conclude: People will inadvertently compare this to virtual methods and
that will lead to surprises and frustration if the mechanics don't match.
If you don't want this to be a half-assed feature where the chain *virtual
-> non-virtual -> virtual* doen't work as expected (leading to "but it
works for non-static! wtf! C++ is inconsistent and stooopid") then you are
going to break the world.

--

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

On Friday, November 13, 2015 at 3:01:34 PM UTC+1, Brent Friedman wrote:<blo=
ckquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-=
left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;bo=
rder-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">=
<div style=3D"font-size:12.8px">=C2=A0struct X {</div><div style=3D"font-si=
ze:12.8px">=C2=A0 =C2=A0 virtual static f() { g(); }</div><div style=3D"fon=
t-size:12.8px">=C2=A0 =C2=A0 virtual static g();</div><div style=3D"font-si=
ze:12.8px">=C2=A0 };</div></blockquote><div><br></div><div>After thinking t=
his over a bit more I think I better understand the subtlety you are pointi=
ng out now.</div><div><br></div><div>Since f is virtual static, it has no &=
#39;this&#39;. Therefore, it could only possibly be X::g. So since this is =
a bit confusing, I&#39;m leaning toward ill-formed and requiring qualified =
ids or explicit member access syntax.</div></div></blockquote><div>This can=
 be fixed by giving it a replacement. Member functions get &quot;this&quot;=
 =C2=A0and thus implicitly know where to find their dynamic vtable.</div><d=
iv>For a static virtual function it would be sufficient to pass it the &quo=
t;static vtable&quot; pointer, i.e. a dynamic vtable containing only the vi=
rtual *static* functions.</div><div>But that breaks as soon as it calls a n=
on-virtual static function, as that vtable pointer is then lost if it isn&#=
39;t also passed to non-virtual static methods.</div><div>But that is a sev=
ere ABI break.</div><div><br></div><div>To conclude:=C2=A0People will inadv=
ertently compare this to virtual methods and that will lead to surprises an=
d frustration if the mechanics don&#39;t match. If you don&#39;t want this =
to be a half-assed feature where the chain *virtual -&gt; non-virtual -&gt;=
 virtual* doen&#39;t work as expected (leading to &quot;but it works for no=
n-static! wtf! C++ is inconsistent and stooopid&quot;) then you are going t=
o break the world.</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_6_160759906.1447464763313--
------=_Part_5_1312308030.1447464763313--

.