aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/std
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2025-06-10 10:15:25 -0400
committerPatrick Palka <ppalka@redhat.com>2025-06-10 10:15:25 -0400
commit1f402fe23b0d4cf024688a729f4c86c37144d54a (patch)
tree614d8df337c4f58a4e9af517b1db5482493abe10 /libstdc++-v3/testsuite/std
parent73edc003c0a8f0badc7027e6deefd3a573300b03 (diff)
downloadgcc-1f402fe23b0d4cf024688a729f4c86c37144d54a.zip
gcc-1f402fe23b0d4cf024688a729f4c86c37144d54a.tar.gz
gcc-1f402fe23b0d4cf024688a729f4c86c37144d54a.tar.bz2
libstdc++: Make __max_size_type and __max_diff_type structural
This patch makes these integer-class types structural types by public-izing their data members so that they could be used as NTTP types. I don't think this is required by the standard, but it seems like a useful extension. libstdc++-v3/ChangeLog: * include/bits/max_size_type.h (__max_size_type::_M_val): Make public instead of private. (__max_size_type::_M_msb): Likewise. (__max_diff_type::_M_rep): Likewise. * testsuite/std/ranges/iota/max_size_type.cc: Verify __max_diff_type and __max_size_type are structural. Reviewed-by: Tomasz KamiƄski <tkaminsk@redhat.com> Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Diffstat (limited to 'libstdc++-v3/testsuite/std')
-rw-r--r--libstdc++-v3/testsuite/std/ranges/iota/max_size_type.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/std/ranges/iota/max_size_type.cc b/libstdc++-v3/testsuite/std/ranges/iota/max_size_type.cc
index 3e6f954..4739d9e 100644
--- a/libstdc++-v3/testsuite/std/ranges/iota/max_size_type.cc
+++ b/libstdc++-v3/testsuite/std/ranges/iota/max_size_type.cc
@@ -400,6 +400,13 @@ static_assert(max_diff_t(max_size_t(1)
<< (numeric_limits<max_size_t>::digits-1))
== numeric_limits<max_diff_t>::min());
+// Verify that the types are structural types and can therefore be used
+// as NTTP types.
+template<max_size_t V> struct Su { static_assert(V*V == V+132); };
+template<max_diff_t V> struct Ss { static_assert(V*V == V+132); };
+template struct Su<12>;
+template struct Ss<12>;
+
int
main()
{