public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 1/4] libstdc++: Reduce the size of an unbounded iota_view
@ 2020-09-28  4:48 Patrick Palka
  2020-09-28  4:48 ` [PATCH 2/4] libstdc++: Reduce the size of a subrange with empty sentinel type Patrick Palka
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Patrick Palka @ 2020-09-28  4:48 UTC (permalink / raw)
  To: gcc-patches; +Cc: libstdc++, Patrick Palka

libstdc++-v3/ChangeLog:

	* include/std/ranges (iota_view::_M_bound): Give it
	[[no_unique_address]].
	* testsuite/std/ranges/iota/iota_view.cc: Check that an
	unbounded iota_view has minimal size.
---
 libstdc++-v3/include/std/ranges                     | 2 +-
 libstdc++-v3/testsuite/std/ranges/iota/iota_view.cc | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index ed04fa0001d..964a2b616a6 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -511,7 +511,7 @@ namespace ranges
       };
 
       _Winc _M_value = _Winc();
-      _Bound _M_bound = _Bound();
+      [[no_unique_address]] _Bound _M_bound = _Bound();
 
     public:
       iota_view() = default;
diff --git a/libstdc++-v3/testsuite/std/ranges/iota/iota_view.cc b/libstdc++-v3/testsuite/std/ranges/iota/iota_view.cc
index 65d166fbd3b..8a33e10a093 100644
--- a/libstdc++-v3/testsuite/std/ranges/iota/iota_view.cc
+++ b/libstdc++-v3/testsuite/std/ranges/iota/iota_view.cc
@@ -77,6 +77,9 @@ test04()
   VERIFY( it == v.end() );
 }
 
+// Verify we optimize away the 'bound' data member of an unbounded iota_view.
+static_assert(sizeof(std::ranges::iota_view<char>) == 1);
+
 int
 main()
 {
-- 
2.28.0.618.g9bc233ae1c


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-09-28 15:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-28  4:48 [PATCH 1/4] libstdc++: Reduce the size of an unbounded iota_view Patrick Palka
2020-09-28  4:48 ` [PATCH 2/4] libstdc++: Reduce the size of a subrange with empty sentinel type Patrick Palka
2020-09-28  9:32   ` Jonathan Wakely
2020-09-28  4:48 ` [PATCH 3/4] libstdc++: Add test that tracks range adaptors' sizes Patrick Palka
2020-09-28  9:32   ` Jonathan Wakely
2020-09-28  4:48 ` [PATCH 4/4] libstdc++: Rearrange some range adaptors' data members Patrick Palka
2020-09-28  9:34   ` Jonathan Wakely
2020-09-28 13:11     ` Patrick Palka
2020-09-28 15:38       ` Jonathan Wakely
2020-09-28  9:31 ` [PATCH 1/4] libstdc++: Reduce the size of an unbounded iota_view Jonathan Wakely

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