Topic: rtti: missing sizeof() and alignof() in std::type_info
Author: Matthew Fioravante <fmatthew5876@gmail.com>
Date: Thu, 6 Aug 2015 13:42:57 -0700 (PDT)
Raw View
------=_Part_1381_849439469.1438893777708
Content-Type: multipart/alternative;
boundary="----=_Part_1382_1534568141.1438893777708"
------=_Part_1382_1534568141.1438893777708
Content-Type: text/plain; charset=UTF-8
Is there any reason that sizeof(T) and alignof(T) are not available via the
type_info struct from typeid()?
I want to use the address and size in particular to create a mapping of
objects within other objects for debugging purposes. It doesn't actually
appear to be possible in C++14 to get the size of the most dynamic type
without rolling your own rtti solution.
What I would suggest is adding size() and align() methods to type_info to
return sizeof(T) and alignof(T) respectively.
--
---
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_1382_1534568141.1438893777708
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Is there any reason that sizeof(T) and alignof(T) are not =
available via the type_info struct from typeid()?<br><br>I want to use the =
address and size in particular to create a mapping of objects within other =
objects for debugging purposes. It doesn't actually appear to be possib=
le in C++14 to get the size of the most dynamic type without rolling your o=
wn rtti solution.<br><br>What I would suggest is adding size() and align() =
methods to type_info to return sizeof(T) and alignof(T) respectively.<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" 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_1382_1534568141.1438893777708--
------=_Part_1381_849439469.1438893777708--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Thu, 6 Aug 2015 14:09:38 -0700 (PDT)
Raw View
------=_Part_1369_2136049608.1438895379044
Content-Type: multipart/alternative;
boundary="----=_Part_1370_738153952.1438895379044"
------=_Part_1370_738153952.1438895379044
Content-Type: text/plain; charset=UTF-8
I wouldn't suggest calling it `size`, as that term is generally reserved
for getting the number of elements in a container object. If we add a
global `size` function that will call member `size` functions (assuming
C++17 doesn't give us the ability to call member functions as if they were
global), you wouldn't want `type_info` to respond to such a function call.
Perhaps `size_of` and `align_of`.
--
---
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_1370_738153952.1438895379044
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I wouldn't suggest calling it `size`, as that term is =
generally reserved for getting the number of elements in a container object=
.. If we add a global `size` function that will call member `size` functions=
(assuming C++17 doesn't give us the ability to call member functions a=
s if they were global), you wouldn't want `type_info` to respond to suc=
h a function call.<br><br>Perhaps `size_of` and `align_of`.<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" 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_1370_738153952.1438895379044--
------=_Part_1369_2136049608.1438895379044--
.
Author: Andrey Semashev <andrey.semashev@gmail.com>
Date: Fri, 7 Aug 2015 01:24:00 +0300
Raw View
On Fri, Aug 7, 2015 at 12:09 AM, Nicol Bolas <jmckesson@gmail.com> wrote:
> I wouldn't suggest calling it `size`, as that term is generally reserved for
> getting the number of elements in a container object. If we add a global
> `size` function that will call member `size` functions (assuming C++17
> doesn't give us the ability to call member functions as if they were
> global), you wouldn't want `type_info` to respond to such a function call.
>
> Perhaps `size_of` and `align_of`.
<bikeshed_mode>'object_size' and 'alignment'?</bikeshed_mode>
An interesting idea at the first glance, this would probably increase
type_info size overhead whether these functions are used or not, and I
expect them to be used rarely. Not sure this is worth it, provided
that an opt-in solution is possible.
--
---
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: Thiago Macieira <thiago@macieira.org>
Date: Thu, 06 Aug 2015 16:43:31 -0700
Raw View
On Thursday 06 August 2015 13:42:57 Matthew Fioravante wrote:
> Is there any reason that sizeof(T) and alignof(T) are not available via the
> type_info struct from typeid()?
>
> I want to use the address and size in particular to create a mapping of
> objects within other objects for debugging purposes. It doesn't actually
> appear to be possible in C++14 to get the size of the most dynamic type
> without rolling your own rtti solution.
>
> What I would suggest is adding size() and align() methods to type_info to
> return sizeof(T) and alignof(T) respectively.
Sounds like a reasonable proposal, but one tricky to implement.
In order to support polymorphic types linked before this feature, it needs to
support returning sizeOf() == alignOf() == 0 or another sentinel value that
indicates absence of information.
Also note that typeid(void) is valid, so what does typeid(void).sizeOf()
return?
--
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/.
.