@@ -73,6 +73,7 @@ public:
73
73
typedef typename traits_type::int_type int_type;
74
74
typedef typename traits_type::pos_type pos_type;
75
75
typedef typename traits_type::off_type off_type;
76
+ using native_handle_type = typename basic_filebuf<charT, traits>::native_handle_type; // Since C++26
76
77
77
78
basic_ifstream();
78
79
explicit basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in);
@@ -85,6 +86,7 @@ public:
85
86
void swap(basic_ifstream& rhs);
86
87
87
88
basic_filebuf<char_type, traits_type>* rdbuf() const;
89
+ native_handle_type native_handle() const noexcept; // Since C++26
88
90
bool is_open() const;
89
91
void open(const char* s, ios_base::openmode mode = ios_base::in);
90
92
void open(const string& s, ios_base::openmode mode = ios_base::in);
@@ -110,6 +112,7 @@ public:
110
112
typedef typename traits_type::int_type int_type;
111
113
typedef typename traits_type::pos_type pos_type;
112
114
typedef typename traits_type::off_type off_type;
115
+ using native_handle_type = typename basic_filebuf<charT, traits>::native_handle_type; // Since C++26
113
116
114
117
basic_ofstream();
115
118
explicit basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out);
@@ -122,6 +125,8 @@ public:
122
125
void swap(basic_ofstream& rhs);
123
126
124
127
basic_filebuf<char_type, traits_type>* rdbuf() const;
128
+ native_handle_type native_handle() const noexcept; // Since C++26
129
+
125
130
bool is_open() const;
126
131
void open(const char* s, ios_base::openmode mode = ios_base::out);
127
132
void open(const string& s, ios_base::openmode mode = ios_base::out);
@@ -148,6 +153,7 @@ public:
148
153
typedef typename traits_type::int_type int_type;
149
154
typedef typename traits_type::pos_type pos_type;
150
155
typedef typename traits_type::off_type off_type;
156
+ using native_handle_type = typename basic_filebuf<charT, traits>::native_handle_type; // Since C++26
151
157
152
158
basic_fstream();
153
159
explicit basic_fstream(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out);
@@ -160,6 +166,7 @@ public:
160
166
void swap(basic_fstream& rhs);
161
167
162
168
basic_filebuf<char_type, traits_type>* rdbuf() const;
169
+ native_handle_type native_handle() const noexcept; // Since C++26
163
170
bool is_open() const;
164
171
void open(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out);
165
172
void open(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out);
@@ -210,6 +217,10 @@ _LIBCPP_PUSH_MACROS
210
217
211
218
_LIBCPP_BEGIN_NAMESPACE_STD
212
219
220
+ # if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_WIN32API)
221
+ _LIBCPP_EXPORTED_FROM_ABI void * __filebuf_windows_native_handle (FILE* __file) noexcept ;
222
+ # endif
223
+
213
224
template <class _CharT , class _Traits >
214
225
class _LIBCPP_TEMPLATE_VIS basic_filebuf : public basic_streambuf<_CharT, _Traits> {
215
226
public:
@@ -219,6 +230,15 @@ public:
219
230
typedef typename traits_type::pos_type pos_type;
220
231
typedef typename traits_type::off_type off_type;
221
232
typedef typename traits_type::state_type state_type;
233
+ # if _LIBCPP_STD_VER >= 26
234
+ # if defined(_LIBCPP_WIN32API)
235
+ using native_handle_type = void *; // HANDLE
236
+ # elif __has_include(<unistd.h>)
237
+ using native_handle_type = int ; // POSIX file descriptor
238
+ # else
239
+ # error "Provide a native file handle!"
240
+ # endif
241
+ # endif
222
242
223
243
// 27.9.1.2 Constructors/destructor:
224
244
basic_filebuf ();
@@ -245,6 +265,18 @@ public:
245
265
# endif
246
266
_LIBCPP_HIDE_FROM_ABI basic_filebuf* __open (int __fd, ios_base::openmode __mode);
247
267
basic_filebuf* close ();
268
+ # if _LIBCPP_STD_VER >= 26
269
+ _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle () const noexcept {
270
+ _LIBCPP_ASSERT_UNCATEGORIZED (this ->is_open (), " File must be opened" );
271
+ # if defined(_LIBCPP_WIN32API)
272
+ return std::__filebuf_windows_native_handle (__file_);
273
+ # elif __has_include(<unistd.h>)
274
+ return fileno (__file_);
275
+ # else
276
+ # error "Provide a way to determine the file native handle!"
277
+ # endif
278
+ }
279
+ # endif // _LIBCPP_STD_VER >= 26
248
280
249
281
_LIBCPP_HIDE_FROM_ABI inline static const char * __make_mdstring (ios_base::openmode __mode) _NOEXCEPT;
250
282
@@ -1024,6 +1056,9 @@ public:
1024
1056
typedef typename traits_type::int_type int_type;
1025
1057
typedef typename traits_type::pos_type pos_type;
1026
1058
typedef typename traits_type::off_type off_type;
1059
+ # if _LIBCPP_STD_VER >= 26
1060
+ using native_handle_type = typename basic_filebuf<_CharT, _Traits>::native_handle_type;
1061
+ # endif
1027
1062
1028
1063
_LIBCPP_HIDE_FROM_ABI basic_ifstream ();
1029
1064
_LIBCPP_HIDE_FROM_ABI explicit basic_ifstream (const char * __s, ios_base::openmode __mode = ios_base::in);
@@ -1041,6 +1076,9 @@ public:
1041
1076
_LIBCPP_HIDE_FROM_ABI void swap (basic_ifstream& __rhs);
1042
1077
1043
1078
_LIBCPP_HIDE_FROM_ABI basic_filebuf<char_type, traits_type>* rdbuf () const ;
1079
+ # if _LIBCPP_STD_VER >= 26
1080
+ _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle () const noexcept { return rdbuf ()->native_handle (); }
1081
+ # endif
1044
1082
_LIBCPP_HIDE_FROM_ABI bool is_open () const ;
1045
1083
void open (const char * __s, ios_base::openmode __mode = ios_base::in);
1046
1084
# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
@@ -1171,6 +1209,9 @@ public:
1171
1209
typedef typename traits_type::int_type int_type;
1172
1210
typedef typename traits_type::pos_type pos_type;
1173
1211
typedef typename traits_type::off_type off_type;
1212
+ # if _LIBCPP_STD_VER >= 26
1213
+ using native_handle_type = typename basic_filebuf<_CharT, _Traits>::native_handle_type;
1214
+ # endif
1174
1215
1175
1216
_LIBCPP_HIDE_FROM_ABI basic_ofstream ();
1176
1217
_LIBCPP_HIDE_FROM_ABI explicit basic_ofstream (const char * __s, ios_base::openmode __mode = ios_base::out);
@@ -1190,6 +1231,9 @@ public:
1190
1231
_LIBCPP_HIDE_FROM_ABI void swap (basic_ofstream& __rhs);
1191
1232
1192
1233
_LIBCPP_HIDE_FROM_ABI basic_filebuf<char_type, traits_type>* rdbuf () const ;
1234
+ # if _LIBCPP_STD_VER >= 26
1235
+ _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle () const noexcept { return rdbuf ()->native_handle (); }
1236
+ # endif
1193
1237
_LIBCPP_HIDE_FROM_ABI bool is_open () const ;
1194
1238
void open (const char * __s, ios_base::openmode __mode = ios_base::out);
1195
1239
# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
@@ -1321,6 +1365,9 @@ public:
1321
1365
typedef typename traits_type::int_type int_type;
1322
1366
typedef typename traits_type::pos_type pos_type;
1323
1367
typedef typename traits_type::off_type off_type;
1368
+ # if _LIBCPP_STD_VER >= 26
1369
+ using native_handle_type = typename basic_filebuf<_CharT, _Traits>::native_handle_type;
1370
+ # endif
1324
1371
1325
1372
_LIBCPP_HIDE_FROM_ABI basic_fstream ();
1326
1373
_LIBCPP_HIDE_FROM_ABI explicit basic_fstream (const char * __s,
@@ -1345,6 +1392,9 @@ public:
1345
1392
_LIBCPP_HIDE_FROM_ABI void swap (basic_fstream& __rhs);
1346
1393
1347
1394
_LIBCPP_HIDE_FROM_ABI basic_filebuf<char_type, traits_type>* rdbuf () const ;
1395
+ # if _LIBCPP_STD_VER >= 26
1396
+ _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle () const noexcept { return rdbuf ()->native_handle (); }
1397
+ # endif
1348
1398
_LIBCPP_HIDE_FROM_ABI bool is_open () const ;
1349
1399
_LIBCPP_HIDE_FROM_ABI void open (const char * __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
1350
1400
# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
0 commit comments