Skip to content

WIP - [libc++][spanstream] P0448R4: A strstream replacement using span<charT> as buffer #83541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 120 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
f2935a6
[libc++][spanstream] P0448R4: A `strstream` replacement using `span<c…
H-G-Hristov Feb 27, 2024
a96a0a2
Added forward declarations to `<iosfwd>`
H-G-Hristov Feb 28, 2024
68f9a3a
Tests: updated `types.compile.pass`
H-G-Hristov Feb 28, 2024
709c27b
Implementation: added `_LIBCPP_HIDE_FROM_ABI`
H-G-Hristov Feb 28, 2024
4cfdff4
Tests: `spanbuf` constructor tests
H-G-Hristov Feb 29, 2024
505fef9
Tests: tweaks
H-G-Hristov Mar 1, 2024
a90b60b
Tests: `ispanstream` constructors - WIP
H-G-Hristov Mar 1, 2024
29bdc6a
Implementation: fixed module and forward declarations
H-G-Hristov Mar 1, 2024
94dd655
Implementation: fixed python code formatting
H-G-Hristov Mar 1, 2024
1d1612a
Implementation: updated transitive includes
H-G-Hristov Mar 1, 2024
9efdaa0
Implementation: fix CI
H-G-Hristov Mar 1, 2024
7373d2b
Implementation: try to fix CI
H-G-Hristov Mar 1, 2024
836b92f
Implementation: fixes
H-G-Hristov Mar 1, 2024
0bd187f
Implementation: fixes
H-G-Hristov Mar 1, 2024
bd24fd0
Tests: `ospanstream` and `spanstream` constructors + fixes
H-G-Hristov Mar 1, 2024
4bc5407
Tests: `ispanstream` added assign and swap
H-G-Hristov Mar 2, 2024
fd1c254
Tests: added `ReadonlySpan` type
H-G-Hristov Mar 3, 2024
bf12527
Tests: WIP `ROS` constructor
H-G-Hristov Mar 4, 2024
a1c51e6
Tests: WIP retry CI
H-G-Hristov Mar 4, 2024
6283a36
Tests: Try to fix CI
H-G-Hristov Mar 5, 2024
d5bbf3f
Tests: updated generated tests
H-G-Hristov Mar 5, 2024
2eb5e6e
Tests: WIP
H-G-Hristov Mar 5, 2024
b2eca6c
Tests: WIP cleanup
H-G-Hristov Mar 5, 2024
df9581c
Tests: added test skelettons
H-G-Hristov Mar 5, 2024
512435a
Tests: updated `iosfwd.pass.cpp`
H-G-Hristov Mar 5, 2024
3125c75
Tests: WIP fix test skelettons
H-G-Hristov Mar 5, 2024
4fbc16b
Tests: try to fix CI
H-G-Hristov Mar 5, 2024
7f1388c
Tests: WIP `span.pass` and `span.span.pass`
H-G-Hristov Mar 6, 2024
197c3be
Tests: updated `span.pass` and `span.span.pass`
H-G-Hristov Mar 6, 2024
ea2ed02
Implementations: `basic_spanbuf` improved constructors and member fun…
H-G-Hristov Mar 9, 2024
c3e0dac
Tests: `basic_spanbuf` improved tests for constructors and member fun…
H-G-Hristov Mar 9, 2024
b5d66b9
Tests: Added `setbuf.pass`
H-G-Hristov Mar 11, 2024
dccf570
Tests: WIP `seekoff`
H-G-Hristov Mar 11, 2024
aa4ab9b
Tests: WIP cleanup
H-G-Hristov Mar 11, 2024
08b4685
Tests: WIP `seekoff`
H-G-Hristov Mar 12, 2024
dee214b
Implementation: `seekoff` no mode is set
H-G-Hristov Mar 12, 2024
b0ea4c3
Tests: WIP `seekoff.pass`
H-G-Hristov Mar 12, 2024
c83a5be
Tests: `seekoff.off_type.seek_dir.open_mode.pass`
H-G-Hristov Mar 13, 2024
5316a76
Tests: clean-up `seekoff.off_type.seek_dir.open_mode.pass`
H-G-Hristov Mar 13, 2024
6e435e0
Tests: updated `seekoff.pass` and `seekpos.pass`
H-G-Hristov Mar 13, 2024
7d17869
Tests: WIP `operator>>` tests
H-G-Hristov Mar 13, 2024
6b67a27
Test: WIP `basic_spanstream`'s `operator>>` and `operator<<`
H-G-Hristov Mar 13, 2024
91c1355
Tests: fixed formatting
H-G-Hristov Mar 13, 2024
c4d1aee
Tests: WIP `spanstream`
H-G-Hristov Mar 15, 2024
19ec42a
Tests: `spanstream`
H-G-Hristov Mar 15, 2024
aa9178f
Tests: Fix CI
H-G-Hristov Mar 15, 2024
4e7e72e
Tests: tweaks `spanbuf` and `spanstream`
H-G-Hristov Mar 15, 2024
186ff77
Tests: updated `spanstream` and `ospanstream`
H-G-Hristov Mar 15, 2024
c82d2c8
Tests: updated `ospanstream`, `spanbuf`, `spanstream`
H-G-Hristov Mar 15, 2024
6315328
Tests: updated and fixed tests
H-G-Hristov Mar 15, 2024
5b11364
Tests: fixed CI
H-G-Hristov Mar 15, 2024
b2ee728
Tests: fixed CI
H-G-Hristov Mar 15, 2024
5d13308
Tests: updated `inherited.stream.ops.pass.cpp`
H-G-Hristov Mar 15, 2024
9decf93
Tests: updated `inherited.stream.ops.pass.cpp`
H-G-Hristov Mar 16, 2024
9d1665a
Tests: `stream.ops.pass.cpp`
H-G-Hristov Mar 17, 2024
21be2dc
Updated Release Notes
H-G-Hristov Jul 19, 2024
4143152
Removed #include <__availability>
H-G-Hristov Jul 19, 2024
09781e4
Removed #include <__assert>
H-G-Hristov Jul 19, 2024
574b727
Updated: libcxx/test/std/input.output/span.streams/ispanstream/ispans…
H-G-Hristov Aug 3, 2024
9f863ed
Updated: libcxx/test/std/input.output/span.streams/ispanstream/ispans…
H-G-Hristov Aug 3, 2024
6730df2
Updated libcxx/test/std/input.output/span.streams/ispanstream/ispanst…
H-G-Hristov Aug 4, 2024
d75e221
Updated libcxx/test/std/input.output/span.streams/ispanstream/ispanst…
H-G-Hristov Aug 4, 2024
b446bd6
Updated libcxx/test/std/input.output/span.streams/ispanstream/ispanst…
H-G-Hristov Aug 4, 2024
6a2d427
Updated libcxx/test/std/input.output/span.streams/ispanstream/ispanst…
H-G-Hristov Aug 4, 2024
c223384
Updated tests
H-G-Hristov Aug 4, 2024
eb9ef80
Updated libcxx/test/std/input.output/span.streams/ispanstream/ispanst…
H-G-Hristov Aug 4, 2024
500b152
Updated libcxx/test/std/input.output/span.streams/ispanstream/ispanst…
H-G-Hristov Aug 5, 2024
e6c4c89
Updated libcxx/test/std/input.output/span.streams/ispanstream/ispanst…
H-G-Hristov Aug 5, 2024
7082f1f
Updated libcxx/test/std/input.output/span.streams/ispanstream/types.c…
H-G-Hristov Aug 5, 2024
b716602
Updated libcxx/test/std/input.output/span.streams/ispanstream/ispanst…
H-G-Hristov Aug 5, 2024
e09c037
Updated ispanstream tests
H-G-Hristov Aug 5, 2024
63f02f9
Added libcxx/test/std/input.output/span.streams/ispanstream/inherited…
H-G-Hristov Aug 5, 2024
af9d416
Updated: libcxx/test/std/input.output/span.streams/ispanstream/inheri…
H-G-Hristov Aug 5, 2024
2838485
ispanstream + constexpr_char_traits: returns empty strings
H-G-Hristov Aug 5, 2024
1997256
Removed constexpr_char_traits from tests
H-G-Hristov Aug 5, 2024
b9d40de
Updated: libcxx/test/std/input.output/span.streams/ospanstream/ospans…
H-G-Hristov Aug 5, 2024
2167a5b
Updated: libcxx/test/std/input.output/span.streams/ospanstream/ospans…
H-G-Hristov Aug 5, 2024
4f0b6e6
Updated: `basic_ostream` tests
H-G-Hristov Aug 5, 2024
01ecbbe
Fixed formatting
H-G-Hristov Aug 5, 2024
f75927b
WIP: ospanstream tests
H-G-Hristov Aug 16, 2024
004baf9
Try to fix merge conflict fixes
H-G-Hristov Oct 8, 2024
fa8ed8c
Fix the fixes that fix the fixes
H-G-Hristov Oct 8, 2024
33f060c
Fixed transitive includes
H-G-Hristov Oct 8, 2024
425e0f4
Fixed transitive includes
H-G-Hristov Oct 8, 2024
b7490de
Try to fix build
H-G-Hristov Oct 10, 2024
81d1ed1
`spanstream` does not support `no-localization`
H-G-Hristov Oct 12, 2024
2839a08
Target LLVM21
H-G-Hristov Feb 13, 2025
580c939
Try to fix CI
H-G-Hristov Feb 13, 2025
dd04528
Try to fix CI
H-G-Hristov Feb 13, 2025
520cbe6
Fix formatting
H-G-Hristov Feb 13, 2025
94d573a
Try to fix CI
H-G-Hristov Feb 13, 2025
11d7a0e
Try to fix CI
H-G-Hristov Feb 13, 2025
78c7e42
Try to fix CI
H-G-Hristov Feb 16, 2025
687ea98
Try to fix CI
H-G-Hristov Feb 16, 2025
e204373
Try to fix CI
H-G-Hristov Feb 16, 2025
c07da7d
Try to fix transitive includes
H-G-Hristov Feb 16, 2025
6c2ae11
Try to fix transitive includes
H-G-Hristov Feb 16, 2025
80e025b
Updated `spanstream` tests REQUIRES condition
H-G-Hristov Mar 10, 2025
8ce2b8e
Cleanup `<spanstream>`
H-G-Hristov Mar 19, 2025
97f19f6
WIP - `ospanstream`
H-G-Hristov Mar 21, 2025
672a2d3
Removed tests for `char8_t`, `char16_t`, `char32_t` as unsupported
H-G-Hristov Mar 21, 2025
5e75d27
WIP - test `ospanstream` inherited stream ops
H-G-Hristov Mar 22, 2025
49ccc7f
Mass test cleanup
H-G-Hristov Mar 28, 2025
5023fa3
Fix CI
H-G-Hristov Mar 28, 2025
df9eaec
WIP: Test spanbuf pointers in streams
H-G-Hristov Apr 1, 2025
22d085c
Removed `_LIBCPP_TEMPLATE_VIS` as of https://github.com/llvm/llvm-pro…
H-G-Hristov May 16, 2025
40e2661
Re-run generator scripts
H-G-Hristov May 16, 2025
628db92
Fixed format
H-G-Hristov May 16, 2025
0ca74dd
Fixed formatting
H-G-Hristov May 16, 2025
a0fcde3
Fixed formatting again
H-G-Hristov May 16, 2025
0090ce1
Run generator scripts
H-G-Hristov May 16, 2025
eda6e7f
Try again
H-G-Hristov May 16, 2025
066872d
Try again
H-G-Hristov May 16, 2025
645f94f
Try again
H-G-Hristov May 16, 2025
5b7abb3
Update libcxx/test/std/language.support/support.limits/support.limits…
H-G-Hristov May 16, 2025
b94890c
Update libcxx/test/std/language.support/support.limits/support.limits…
H-G-Hristov May 16, 2025
5e314c3
Fix CI - `addressof`
H-G-Hristov May 18, 2025
73088da
Update libcxx/docs/Status/Cxx23Papers.csv
H-G-Hristov Jul 22, 2025
5b78b4d
LLVM22
H-G-Hristov Jul 22, 2025
a8ada49
Transitive includes
H-G-Hristov Jul 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libcxx/docs/FeatureTestMacroTable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ Status
---------------------------------------------------------- -----------------
``__cpp_lib_reference_from_temporary`` *unimplemented*
---------------------------------------------------------- -----------------
``__cpp_lib_spanstream`` *unimplemented*
``__cpp_lib_spanstream`` ``202106L``
---------------------------------------------------------- -----------------
``__cpp_lib_stacktrace`` *unimplemented*
---------------------------------------------------------- -----------------
Expand Down
1 change: 1 addition & 0 deletions libcxx/docs/ReleaseNotes/22.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Implemented Papers
------------------

- P2321R2: ``zip`` (`Github <https://github.com/llvm/llvm-project/issues/105169>`__) (The paper is partially implemented. ``zip_transform_view`` is implemented in this release)
- P0448R4: A ``strstream`` replacement using ``span<charT>`` as buffer (`Github <https://github.com/llvm/llvm-project/issues/105145>`__)

Improvements and New Features
-----------------------------
Expand Down
2 changes: 1 addition & 1 deletion libcxx/docs/Status/Cxx23Papers.csv
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"`P2259R1 <https://wg21.link/P2259R1>`__","Repairing input range adaptors and counted_iterator","2021-02 (Virtual)","","",""
"","","","","",""
"`P0401R6 <https://wg21.link/P0401R6>`__","Providing size feedback in the Allocator interface","2021-06 (Virtual)","|Complete|","15",""
"`P0448R4 <https://wg21.link/P0448R4>`__","A strstream replacement using span<charT> as buffer","2021-06 (Virtual)","","",""
"`P0448R4 <https://wg21.link/P0448R4>`__","A ``strstream`` replacement using ``span<charT>`` as buffer","2021-06 (Virtual)","|Complete|","22"
"`P1132R8 <https://wg21.link/P1132R8>`__","out_ptr - a scalable output pointer abstraction","2021-06 (Virtual)","|Complete|","19",""
"`P1328R1 <https://wg21.link/P1328R1>`__","Making std::type_info::operator== constexpr","2021-06 (Virtual)","|Complete|","17",""
"`P1425R4 <https://wg21.link/P1425R4>`__","Iterators pair constructors for stack and queue","2021-06 (Virtual)","|Complete|","14",""
Expand Down
2 changes: 2 additions & 0 deletions libcxx/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ set(files
__fwd/queue.h
__fwd/set.h
__fwd/span.h
__fwd/spanstream.h
__fwd/sstream.h
__fwd/stack.h
__fwd/streambuf.h
Expand Down Expand Up @@ -1056,6 +1057,7 @@ set(files
shared_mutex
source_location
span
spanstream
sstream
stack
stdatomic.h
Expand Down
48 changes: 48 additions & 0 deletions libcxx/include/__fwd/spanstream.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef _LIBCPP___FWD_SPANSTREAM_H
#define _LIBCPP___FWD_SPANSTREAM_H

#include <__config>
#include <__fwd/string.h>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif

_LIBCPP_BEGIN_NAMESPACE_STD

#if _LIBCPP_STD_VER >= 23

template <class _CharT, class _Traits = char_traits<_CharT>>
class basic_spanbuf;
template <class _CharT, class _Traits = char_traits<_CharT>>
class basic_ispanstream;
template <class _CharT, class _Traits = char_traits<_CharT>>
class basic_ospanstream;
template <class _CharT, class _Traits = char_traits<_CharT>>
class basic_spanstream;

using spanbuf = basic_spanbuf<char>;
using ispanstream = basic_ispanstream<char>;
using ospanstream = basic_ospanstream<char>;
using spanstream = basic_spanstream<char>;

# if _LIBCPP_HAS_WIDE_CHARACTERS
using wspanbuf = basic_spanbuf<wchar_t>;
using wispanstream = basic_ispanstream<wchar_t>;
using wospanstream = basic_ospanstream<wchar_t>;
using wspanstream = basic_spanstream<wchar_t>;
# endif

#endif // _LIBCPP_STD_VER >= 23

_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP___FWD_SPANSTREAM_H
20 changes: 20 additions & 0 deletions libcxx/include/iosfwd
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ template <class charT, class traits = char_traits<charT>, class Allocator = allo
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
class basic_stringstream;

template<class charT, class traits = char_traits<charT>>
class basic_spanbuf; // Since C++23
template<class charT, class traits = char_traits<charT>>
class basic_ispanstream; // Since C++23
template<class charT, class traits = char_traits<charT>>
class basic_ospanstream; // Since C++23
template<class charT, class traits = char_traits<charT>>
class basic_spanstream; // Since C++23

template <class charT, class traits = char_traits<charT> > class basic_filebuf;
template <class charT, class traits = char_traits<charT> > class basic_ifstream;
template <class charT, class traits = char_traits<charT> > class basic_ofstream;
Expand All @@ -62,6 +71,11 @@ typedef basic_istringstream<char> istringstream;
typedef basic_ostringstream<char> ostringstream;
typedef basic_stringstream<char> stringstream;

using spanbuf = basic_spanbuf<char>; // Since C++23
using ispanstream = basic_ispanstream<char>; // Since C++23
using ospanstream = basic_ospanstream<char>; // Since C++23
using spanstream = basic_spanstream<char>; // Since C++23

typedef basic_filebuf<char> filebuf;
typedef basic_ifstream<char> ifstream;
typedef basic_ofstream<char> ofstream;
Expand All @@ -77,6 +91,11 @@ typedef basic_istringstream<wchar_t> wistringstream;
typedef basic_ostringstream<wchar_t> wostringstream;
typedef basic_stringstream<wchar_t> wstringstream;

using wspanbuf = basic_spanbuf<wchar_t>; // Since C++23
using wispanstream = basic_ispanstream<wchar_t>; // Since C++23
using wospanstream = basic_ospanstream<wchar_t>; // Since C++23
using wspanstream = basic_spanstream<wchar_t>; // Since C++23

typedef basic_filebuf<wchar_t> wfilebuf;
typedef basic_ifstream<wchar_t> wifstream;
typedef basic_ofstream<wchar_t> wofstream;
Expand Down Expand Up @@ -114,6 +133,7 @@ using wosyncstream = basic_osyncstream<wchar_t>; // C++20
# include <__fwd/istream.h>
# include <__fwd/memory.h>
# include <__fwd/ostream.h>
# include <__fwd/spanstream.h>
# include <__fwd/sstream.h>
# include <__fwd/streambuf.h>
# include <__fwd/string.h>
Expand Down
7 changes: 7 additions & 0 deletions libcxx/include/module.modulemap.in
Original file line number Diff line number Diff line change
Expand Up @@ -1997,6 +1997,13 @@ module std [system] {
export std.iterator.reverse_iterator
}

module spanstream {
module fwd { header "__fwd/spanstream.h" }

header "spanstream"
export *
}

module sstream {
module fwd { header "__fwd/sstream.h" }

Expand Down
Loading
Loading