Topic: analogue of boost::size()
Author: Viacheslav Usov <via.usov@gmail.com>
Date: Tue, 15 Dec 2015 15:50:22 +0100
Raw View
--001a113d56febff7130526f0e8b9
Content-Type: text/plain; charset=UTF-8
Is there an existing proposal for, or perhaps an existing language feature,
that can be used like boost::size() on basic arrays (not std::arrays) to
obtain its size in elements? The idiom sizeof (arr) / sizeof (arr[0]) is
well-known and, without constexpr, there was no full equivalent of it.
Note my question is about something as simple as std::size(x); I know I can
build one from other things like as std::begin() and std::end(), but then I
would need to wrap that into some compact function; having to write these
wrappers (or macros earlier) is precisely what I find desirable to avoid.
Cheers,
V.
--
---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
--001a113d56febff7130526f0e8b9
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Is there an existing proposal for, or perhaps an existing =
language feature, that can be used like boost::size() on basic arrays (not =
std::arrays) to obtain its size in elements? The idiom sizeof (arr) / sizeo=
f (arr[0]) is well-known and, without constexpr, there was no full equivale=
nt of it.<div><br></div><div>Note my question is about something as simple =
as std::size(x); I know I can build one from other things like as std::begi=
n() and std::end(), but then I would need to wrap that into some compact fu=
nction; having to write these wrappers (or macros earlier) is precisely wha=
t I find desirable to avoid.</div><div><br></div><div>Cheers,<br></div><div=
>V.</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" 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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
--001a113d56febff7130526f0e8b9--
.
Author: =?UTF-8?Q?Daniel_Kr=C3=BCgler?= <daniel.kruegler@gmail.com>
Date: Tue, 15 Dec 2015 16:15:44 +0100
Raw View
2015-12-15 15:50 GMT+01:00 Viacheslav Usov <via.usov@gmail.com>:
> Is there an existing proposal for, or perhaps an existing language feature,
> that can be used like boost::size() on basic arrays (not std::arrays) to
> obtain its size in elements? The idiom sizeof (arr) / sizeof (arr[0]) is
> well-known and, without constexpr, there was no full equivalent of it.
It's already part of the current working draft, see header <iterator>,
which provides free, constexpr function templates, supporting both
built-in arrays and types that have a size() member function.
> Note my question is about something as simple as std::size(x); I know I can
> build one from other things like as std::begin() and std::end(), but then I
> would need to wrap that into some compact function; having to write these
> wrappers (or macros earlier) is precisely what I find desirable to avoid.
Exactly this std::size function does already exist.
- Daniel
--
---
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 https://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: Viacheslav Usov <via.usov@gmail.com>
Date: Tue, 15 Dec 2015 16:31:51 +0100
Raw View
--001a1134e2d81d6b4c0526f17d75
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Thanks. So now I just need to figure out what compilers already support
that.
Cheers,
V.
On Tue, Dec 15, 2015 at 4:15 PM, Daniel Kr=C3=BCgler <daniel.kruegler@gmail=
..com>
wrote:
> 2015-12-15 15:50 GMT+01:00 Viacheslav Usov <via.usov@gmail.com>:
> > Is there an existing proposal for, or perhaps an existing language
> feature,
> > that can be used like boost::size() on basic arrays (not std::arrays) t=
o
> > obtain its size in elements? The idiom sizeof (arr) / sizeof (arr[0]) i=
s
> > well-known and, without constexpr, there was no full equivalent of it.
>
> It's already part of the current working draft, see header <iterator>,
> which provides free, constexpr function templates, supporting both
> built-in arrays and types that have a size() member function.
>
> > Note my question is about something as simple as std::size(x); I know I
> can
> > build one from other things like as std::begin() and std::end(), but
> then I
> > would need to wrap that into some compact function; having to write the=
se
> > wrappers (or macros earlier) is precisely what I find desirable to avoi=
d.
>
> Exactly this std::size function does already exist.
>
> - Daniel
>
> --
>
> ---
> 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
> https://groups.google.com/a/isocpp.org/group/std-proposals/.
>
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-propos=
als/.
--001a1134e2d81d6b4c0526f17d75
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Thanks. So now I just need to figure out what compilers al=
ready support that.<div><br></div><div>Cheers,</div><div>V.</div></div><div=
class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Tue, Dec 15, 2015 =
at 4:15 PM, Daniel Kr=C3=BCgler <span dir=3D"ltr"><<a href=3D"mailto:dan=
iel.kruegler@gmail.com" target=3D"_blank">daniel.kruegler@gmail.com</a>>=
</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .=
8ex;border-left:1px #ccc solid;padding-left:1ex">2015-12-15 15:50 GMT+01:00=
Viacheslav Usov <<a href=3D"mailto:via.usov@gmail.com">via.usov@gmail.c=
om</a>>:<br>
> Is there an existing proposal for, or perhaps an existing language fea=
ture,<br>
> that can be used like boost::size() on basic arrays (not std::arrays) =
to<br>
> obtain its size in elements? The idiom sizeof (arr) / sizeof (arr[0]) =
is<br>
> well-known and, without constexpr, there was no full equivalent of it.=
<br>
<br>
It's already part of the current working draft, see header <iterator=
>,<br>
which provides free, constexpr function templates, supporting both<br>
built-in arrays and types that have a size() member function.<br>
<br>
> Note my question is about something as simple as std::size(x); I know =
I can<br>
> build one from other things like as std::begin() and std::end(), but t=
hen I<br>
> would need to wrap that into some compact function; having to write th=
ese<br>
> wrappers (or macros earlier) is precisely what I find desirable to avo=
id.<br>
<br>
Exactly this std::size function does already exist.<br>
<span class=3D"HOEnZb"><font color=3D"#888888"><br>
- Daniel<br>
<br>
--<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%2Bunsubscribe@isocpp.org">std-propo=
sals+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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/" rel=3D"noreferrer" target=3D"_blank">https://groups.google=
..com/a/isocpp.org/group/std-proposals/</a>.<br>
</font></span></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" 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"https://groups.google.com/a/isocpp.org/group=
/std-proposals/">https://groups.google.com/a/isocpp.org/group/std-proposals=
/</a>.<br />
--001a1134e2d81d6b4c0526f17d75--
.