public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/96710] __int128 vs <type_traits>
Date: Wed, 18 May 2022 12:42:27 +0000 [thread overview]
Message-ID: <bug-96710-4-dWQHtTpRoJ@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96710-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96710
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #0)
> Our definitions of is_scalar depends on is_arithmetic, so
> is_scalar<__int128> is false, and therefore is_object<__int128> is false.
> This is clearly nonsense.
Hmm, what I wrote is nonsense. Our is_object does not depend on is_scalar:
/// is_object
template<typename _Tp>
struct is_object
: public __not_<__or_<is_function<_Tp>, is_reference<_Tp>,
is_void<_Tp>>>::type
{ };
So is_object<__int128> is always true.
But is_scalar<__int128> still depends on __STRICT_ANSI__ which seems wrong.
It's not a compound type, so it's scalar.
Currently we define is_scalar as:
template<typename _Tp>
struct is_scalar
: public __or_<is_arithmetic<_Tp>, is_enum<_Tp>, is_pointer<_Tp>,
is_member_pointer<_Tp>, is_null_pointer<_Tp>>::type
{ };
I think a better definition would be:
template<typename _Tp>
struct is_scalar
: public __and_<is_object<_Tp>, __not_<is_array<_Tp>>,
__not_<is_class<_Tp>>,
__not_<is_union<_Tp>>>
{ };
Which could be optimized using partial specializations for the array cases:
template<typename _Tp>
struct is_scalar
: public __and_<is_object<_Tp>, __not_<is_class<_Tp>>,
__not_<is_union<_Tp>>>
{ };
template<typename _Tp>
struct is_scalar<_Tp[]>
: public false_type
{ };
template<typename _Tp, size_t _Num>
struct is_scalar<_Tp[_Num]>
: public false_type
{ };
next prev parent reply other threads:[~2022-05-18 12:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-19 15:08 [Bug libstdc++/96710] New: " redi at gcc dot gnu.org
2020-12-10 15:30 ` [Bug libstdc++/96710] " redi at gcc dot gnu.org
2022-05-18 12:42 ` redi at gcc dot gnu.org [this message]
2024-02-06 11:12 ` redi at gcc dot gnu.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-96710-4-dWQHtTpRoJ@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).