forked from cplusplus/draft
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuture.tex
More file actions
1387 lines (1190 loc) · 34.7 KB
/
future.tex
File metadata and controls
1387 lines (1190 loc) · 34.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%!TEX root = std.tex
\normannex{depr}{Compatibility features}
\pnum
This Clause describes features of the \Cpp Standard that are specified for compatibility with
existing implementations.
\pnum
These are deprecated features, where
\term{deprecated}
is defined as:
Normative for the current edition of the Standard,
but having been identified as a candidate for removal from future revisions.
An implementation may declare library names and entities described in this section with the
\tcode{deprecated} attribute~(\ref{dcl.attr.deprecated}).
\rSec1[depr.incr.bool]{Increment operator with \tcode{bool} operand}
\pnum
The use of an operand of type
\tcode{bool}
with the
\tcode{++}
operator is deprecated (see~\ref{expr.pre.incr} and~\ref{expr.post.incr}).
\rSec1[depr.register]{\tcode{register} keyword}
\pnum
The use of the \tcode{register} keyword as a
\grammarterm{storage-class-specifier}~(\ref{dcl.stc}) is deprecated.
\rSec1[depr.impldec]{Implicit declaration of copy functions}
\pnum
The implicit definition of a copy constructor
as defaulted
is deprecated if the class has a
user-declared copy assignment operator or a user-declared destructor. The implicit
definition of a copy assignment operator
as defaulted is deprecated if the class has a user-declared
copy constructor or a user-declared destructor (\ref{class.dtor},~\ref{class.copy}).
In a future revision of this International Standard, these implicit definitions
could become deleted~(\ref{dcl.fct.def}).
\rSec1[depr.except.spec]{Dynamic exception specifications}
\pnum
The use of \grammarterm{dynamic-exception-specification}{s} is deprecated.
\rSec1[depr.c.headers]{C standard library headers}
\pnum
For compatibility with the
\indextext{library!C standard}%
C standard library and the C Unicode TR, the \Cpp standard library provides
the 26 \textit{C headers}, as shown in Table~\ref{tab:future.c.headers}.
\begin{floattable}{C headers}{tab:future.c.headers}
{lllll}
\topline
\tcode{<assert.h>} &
\tcode{<inttypes.h>} &
\tcode{<signal.h>} &
\tcode{<stdio.h>} &
\tcode{<wchar.h>} \\
\tcode{<complex.h>} &
\tcode{<iso646.h>} &
\tcode{<stdalign.h>} &
\tcode{<stdlib.h>} &
\tcode{<wctype.h>} \\
\tcode{<ctype.h>} &
\tcode{<limits.h>} &
\tcode{<stdarg.h>} &
\tcode{<string.h>} & \\
\tcode{<errno.h>} &
\tcode{<locale.h>} &
\tcode{<stdbool.h>} &
\tcode{<tgmath.h>} & \\
\tcode{<fenv.h>} &
\tcode{<math.h>} &
\tcode{<stddef.h>} &
\tcode{<time.h>} & \\
\tcode{<float.h>} &
\tcode{<setjmp.h>} &
\tcode{<stdint.h>} &
\tcode{<uchar.h>} & \\
\end{floattable}
\pnum
Every C header, each of which has a name of the form
\indextext{header!C}%
\tcode{name.h},
behaves as if each name placed in the standard library namespace by
the corresponding
\tcode{c\textit{name}}
header is placed within
the global namespace scope. It is unspecified whether these names are first declared or defined within
namespace scope~(\ref{basic.scope.namespace}) of the namespace
\tcode{std} and are then injected into the global namespace scope by
explicit \grammarterm{using-declaration}{s}~(\ref{namespace.udecl}).
\indextext{namespace}%
\pnum
\enterexample
The header
\indexlibrary{\idxhdr{cstdlib}}%
\indexlibrary{\idxhdr{stdlib.h}}%
\tcode{<cstdlib>} assuredly
provides its declarations and definitions within the namespace
\tcode{std}. It may also provide these names within the
global namespace.
The header
\tcode{<stdlib.h>}
assuredly provides the same declarations and definitions within
the global namespace,
much as in the C Standard. It may also provide these names within
the namespace \tcode{std}.
\exitexample
\rSec1[depr.ios.members]{Old iostreams members}
\pnum
The following member names are in addition to names specified in
Clause~\ref{input.output}:
\begin{codeblock}
namespace std {
class ios_base {
public:
typedef @\textit{T1}@ io_state;
typedef @\textit{T2}@ open_mode;
typedef @\textit{T3}@ seek_dir;
typedef @\impdef@ streamoff;
typedef @\impdef@ streampos;
// remainder unchanged
};
}
\end{codeblock}
\pnum
The type \tcode{io_state} is a synonym for an integer type
(indicated here as \tcode{T1} ) that permits certain member functions to
overload others on parameters of type \tcode{iostate} and provide the
same behavior.
\pnum
The type \tcode{open_mode} is a synonym for an integer type
(indicated here as \tcode{T2} ) that permits certain member functions to
overload others on parameters of type \tcode{openmode} and provide the
same behavior.
\pnum
The type \tcode{seek_dir} is a synonym for an integer type
(indicated here as \tcode{T3} ) that permits certain member functions to
overload others on parameters of type \tcode{seekdir} and provide the
same behavior.
\pnum
The type
\indexlibrary{\idxcode{streamoff}}%
\tcode{streamoff}
is an
\impldef{type of \tcode{ios_base::streamoff}} type
that satisfies the requirements of
off_type in~\ref{iostreams.limits.pos}.
\pnum
The type
\tcode{streampos}
is an
\impldef{type of \tcode{ios_base::streampos}} type
that satisfies the requirements of
pos_type in~\ref{iostreams.limits.pos}.
\pnum
An implementation may provide the following additional member function, which has the
effect of calling
\tcode{sbumpc()}~(\ref{streambuf.pub.get}):
\begin{codeblock}
namespace std {
template<class charT, class traits = char_traits<charT> >
class basic_streambuf {
public:
void stossc();
// remainder unchanged
};
}
\end{codeblock}
\pnum
An implementation may provide the following member functions that overload signatures
specified in Clause~\ref{input.output}:
\begin{codeblock}
namespace std {
template<class charT, class traits> class basic_ios {
public:
void clear(io_state state);
void setstate(io_state state);
void exceptions(io_state);
// remainder unchanged
};
class ios_base {
public:
// remainder unchanged
};
template<class charT, class traits = char_traits<charT> >
class basic_streambuf {
public:
pos_type pubseekoff(off_type off, ios_base::seek_dir way,
ios_base::open_mode which = ios_base::in | ios_base::out);
pos_type pubseekpos(pos_type sp,
ios_base::open_mode which);
// remainder unchanged
};
template <class charT, class traits = char_traits<charT> >
class basic_filebuf : public basic_streambuf<charT,traits> {
public:
basic_filebuf<charT,traits>* open
(const char* s, ios_base::open_mode mode);
// remainder unchanged
};
template <class charT, class traits = char_traits<charT> >
class basic_ifstream : public basic_istream<charT,traits> {
public:
void open(const char* s, ios_base::open_mode mode);
// remainder unchanged
};
template <class charT, class traits = char_traits<charT> >
class basic_ofstream : public basic_ostream<charT,traits> {
public:
void open(const char* s, ios_base::open_mode mode);
// remainder unchanged
};
}
\end{codeblock}
\pnum
The effects of these functions is to call the corresponding member function specified
in Clause~\ref{input.output}.
\rSec1[depr.str.strstreams]{\tcode{char*} streams}
\pnum
The header
\tcode{<strstream>}
defines three types that associate stream buffers with
character array objects and assist reading and writing such objects.
\rSec2[depr.strstreambuf]{Class \tcode{strstreambuf}}
\indexlibrary{\idxcode{strstreambuf}}%
\begin{codeblock}
namespace std {
class strstreambuf : public basic_streambuf<char> {
public:
explicit strstreambuf(streamsize alsize_arg = 0);
strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));
strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0);
strstreambuf(const char* gnext_arg, streamsize n);
strstreambuf(signed char* gnext_arg, streamsize n,
signed char* pbeg_arg = 0);
strstreambuf(const signed char* gnext_arg, streamsize n);
strstreambuf(unsigned char* gnext_arg, streamsize n,
unsigned char* pbeg_arg = 0);
strstreambuf(const unsigned char* gnext_arg, streamsize n);
virtual ~strstreambuf();
void freeze(bool freezefl = true);
char* str();
int pcount();
protected:
virtual int_type overflow (int_type c = EOF);
virtual int_type pbackfail(int_type c = EOF);
virtual int_type underflow();
virtual pos_type seekoff(off_type off, ios_base::seekdir way,
ios_base::openmode which
= ios_base::in | ios_base::out);
virtual pos_type seekpos(pos_type sp, ios_base::openmode which
= ios_base::in | ios_base::out);
virtual streambuf* setbuf(char* s, streamsize n);
private:
typedef T1 strstate; // \expos
static const strstate allocated; // \expos
static const strstate constant; // \expos
static const strstate dynamic; // \expos
static const strstate frozen; // \expos
strstate strmode; // \expos
streamsize alsize; // \expos
void* (*palloc)(size_t); // \expos
void (*pfree)(void*); // \expos
};
}
\end{codeblock}
\pnum
The class
\tcode{strstreambuf}
associates the input sequence, and possibly the output sequence, with an object of some
\textit{character}
array type, whose elements store arbitrary values.
The array object has several attributes.
\pnum
\enternote
For the sake of exposition, these are represented as elements of a bitmask type
(indicated here as \tcode{T1}) called \tcode{strstate}.
The elements are:
\begin{itemize}
\item
\tcode{allocated}, set when a dynamic array object has been
allocated, and hence should be freed by the destructor for the
\tcode{strstreambuf} object;
\item
\tcode{constant}, set when the array object has
\tcode{const} elements, so the output sequence cannot be written;
\item
\tcode{dynamic}, set when the array object is allocated
(or reallocated)
as necessary to hold a character sequence that can change in length;
\item
\tcode{frozen}, set when the program has requested that the
array object not be altered, reallocated, or freed.
\end{itemize}
\exitnote
\pnum
\enternote
For the sake of exposition, the maintained data is presented here as:
\begin{itemize}
\item
\tcode{strstate strmode}, the attributes of the array object
associated with the \tcode{strstreambuf} object;
\item
\tcode{int alsize}, the suggested minimum size for a
dynamic array object;
\item
\tcode{void* (*palloc)(size_t)}, points to the function
to call to allocate a dynamic array object;
\item
\tcode{void (*pfree)(void*)}, points to the function to
call to free a dynamic array object.
\end{itemize}
\exitnote
\pnum
Each object of class
\tcode{strstreambuf}
has a
\term{seekable area},
delimited by the pointers \tcode{seeklow} and \tcode{seekhigh}.
If \tcode{gnext} is a null pointer, the seekable area is undefined.
Otherwise, \tcode{seeklow} equals \tcode{gbeg} and
\tcode{seekhigh} is either \tcode{pend},
if \tcode{pend} is not a null pointer, or \tcode{gend}.
\rSec3[depr.strstreambuf.cons]{\tcode{strstreambuf} constructors}
\indexlibrary{\idxcode{strstreambuf}!\tcode{strstreambuf}}%
\begin{itemdecl}
explicit strstreambuf(streamsize alsize_arg = 0);
\end{itemdecl}
\begin{itemdescr}
\pnum
\effects
Constructs an object of class
\tcode{strstreambuf},
initializing the base class with
\tcode{streambuf()}.
The postconditions of this function are indicated in Table~\ref{tab:future.strstreambuf.effects}.
\end{itemdescr}
\begin{libtab2}{\tcode{strstreambuf(streamsize)} effects}{tab:future.strstreambuf.effects}
{ll}
{Element}{Value}
\tcode{strmode} & \tcode{dynamic} \\
\tcode{alsize} & \tcode{alsize_arg} \\
\tcode{palloc} & a null pointer \\
\tcode{pfree} & a null pointer \\
\end{libtab2}
\indexlibrary{\idxcode{strstreambuf}}%
\begin{itemdecl}
strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));
\end{itemdecl}
\begin{itemdescr}
\pnum
\effects
Constructs an object of class
\tcode{strstreambuf},
initializing the base class with
\tcode{streambuf()}.
The postconditions of this function are indicated in Table~\ref{tab:future.strstreambuf1.effects}.
\begin{libtab2}{\tcode{strstreambuf(void* (*)(size_t), void (*)(void*))} effects}
{tab:future.strstreambuf1.effects}
{ll}
{Element}{Value}
\tcode{strmode} & \tcode{dynamic} \\
\tcode{alsize} & an unspecified value \\
\tcode{palloc} & \tcode{palloc_arg} \\
\tcode{pfree} & \tcode{pfree_arg} \\
\end{libtab2}
\end{itemdescr}
\indextext{unspecified}%
\begin{itemdecl}
strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0);
strstreambuf(signed char* gnext_arg, streamsize n,
signed char* pbeg_arg = 0);
strstreambuf(unsigned char* gnext_arg, streamsize n,
unsigned char* pbeg_arg = 0);
\end{itemdecl}
\begin{itemdescr}
\pnum
\effects
Constructs an object of class
\tcode{strstreambuf},
initializing the base class with
\tcode{streambuf()}.
The postconditions of this function are indicated in Table~\ref{tab:future.strstreambuf2.effects}.
\begin{libtab2}{\tcode{strstreambuf(charT*, streamsize, charT*)} effects}
{tab:future.strstreambuf2.effects}
{ll}
{Element}{Value}
\tcode{strmode} & 0 \\
\tcode{alsize} & an unspecified value \\
\tcode{palloc} & a null pointer \\
\tcode{pfree} & a null pointer \\
\end{libtab2}
\pnum
\tcode{gnext_arg} shall point to the first element of an array
object whose number of elements \tcode{N} is determined as follows:
\begin{itemize}
\item
If
\tcode{n > 0},
\tcode{N} is \tcode{n}.
\item
If
\tcode{n == 0},
\tcode{N} is
\tcode{std::strlen(gnext_arg)}.
\indexlibrary{\idxcode{strlen}}%
\item
If
\tcode{n < 0},
\tcode{N} is
\tcode{INT_MAX}.\footnote{The function signature
\tcode{strlen(const char*)}
is declared in
\tcode{<cstring>}.
\indexlibrary{\idxcode{strlen}}%
\indexlibrary{\idxhdr{cstring}}%
(\ref{c.strings}).
The macro
\tcode{INT_MAX}
is defined in
\tcode{<climits>}~(\ref{support.limits}).
\indexlibrary{\idxhdr{climits}}}
\end{itemize}
\pnum
If \tcode{pbeg_arg} is a null pointer, the function executes:
\indexlibrary{\idxcode{strstreambuf}!\idxcode{setg}}%
\indexlibrary{\idxcode{setg}!\idxcode{strstreambuf}}%
\begin{itemdecl}
setg(gnext_arg, gnext_arg, gnext_arg + N);
\end{itemdecl}
\pnum
Otherwise, the function executes:
\begin{codeblock}
setg(gnext_arg, gnext_arg, pbeg_arg);
setp(pbeg_arg, pbeg_arg + N);
strstreambuf(const char* gnext_arg, streamsize n);
strstreambuf(const signed char* gnext_arg, streamsize n);
strstreambuf(const unsigned char* gnext_arg, streamsize n);
\end{codeblock}
\pnum
\effects
Behaves the same as
\tcode{strstreambuf((char*)gnext_arg,n)},
except that the constructor also sets \tcode{constant} in \tcode{strmode}.
\end{itemdescr}
\indexlibrary{\idxcode{strstreambuf}!destructor}%
\begin{itemdecl}
virtual ~strstreambuf();
\end{itemdecl}
\begin{itemdescr}
\pnum
\effects
Destroys an object of class
\tcode{strstreambuf}.
The function frees the dynamically allocated array object only if
\tcode{strmode \& allocated != 0}
and
\tcode{strmode \& frozen == 0}.~(\ref{depr.strstreambuf.virtuals} describes how a dynamically allocated array object is freed.)
\end{itemdescr}
\rSec3[depr.strstreambuf.members]{Member functions}
\indexlibrary{\idxcode{freeze}!\idxcode{strstreambuf}}%
\begin{itemdecl}
void freeze(bool freezefl = true);
\end{itemdecl}
\begin{itemdescr}
\pnum
\effects
If \tcode{strmode} \& \tcode{dynamic} is non-zero, alters the
freeze status of the dynamic array object as follows:
\begin{itemize}
\item
If \tcode{freezefl} is
\tcode{true},
the function sets \tcode{frozen} in \tcode{strmode}.
\item
Otherwise, it clears \tcode{frozen} in \tcode{strmode}.
\end{itemize}
\end{itemdescr}
\indexlibrary{\idxcode{str}!\idxcode{strstreambuf}}%
\begin{itemdecl}
char* str();
\end{itemdecl}
\begin{itemdescr}
\pnum
\effects
Calls
\tcode{freeze()},
then returns the beginning pointer for the input sequence, \tcode{gbeg}.
\pnum
\notes
The return value can be a null pointer.
\end{itemdescr}
\indexlibrary{\idxcode{pcount}!\idxcode{strstreambuf}}%
\begin{itemdecl}
int pcount() const;
\end{itemdecl}
\begin{itemdescr}
\pnum
\effects
If the next pointer for the output sequence, \tcode{pnext}, is
a null pointer, returns zero.
Otherwise, returns the current
effective length of the array object as the next pointer minus the beginning
pointer for the output sequence, \tcode{pnext} - \tcode{pbeg}.
\end{itemdescr}
\rSec3[depr.strstreambuf.virtuals]{\tcode{strstreambuf} overridden virtual functions}
\indexlibrary{\idxcode{overflow}!\idxcode{strstreambuf}}%
\begin{itemdecl}
int_type overflow(int_type c = EOF);
\end{itemdecl}
\begin{itemdescr}
\pnum
\effects
Appends the character designated by \tcode{c} to the output
sequence, if possible, in one of two ways:
\begin{itemize}
\item
If
\tcode{c != EOF}
and if either the output sequence has a write position available or
the function makes a write position available
(as described below),
assigns \tcode{c} to
\tcode{*pnext++}.
Returns
\tcode{(unsigned char)c}.
\item
If
\tcode{c == EOF},
there is no character to append.
Returns a value other than \tcode{EOF}.
\end{itemize}
\pnum
Returns
\tcode{EOF}
to indicate failure.
\pnum
\notes
The function can alter the number of write positions available as a
result of any call.
\pnum
To make a write position available, the function reallocates
(or initially allocates)
an array object with a sufficient number of elements
\tcode{n} to hold the current array object (if any),
plus at least one additional write position.
How many additional write positions are made
available is otherwise unspecified.%
\indextext{unspecified}%
\footnote{An implementation should consider \tcode{alsize} in making this
decision.}
If \tcode{palloc} is not a null pointer, the function calls
\tcode{(*palloc)(n)}
to allocate the new dynamic array object.
Otherwise, it evaluates the expression
\tcode{new charT[n]}.
In either case, if the allocation fails, the function returns
\tcode{EOF}.
Otherwise, it sets \tcode{allocated} in \tcode{strmode}.
\pnum
To free a previously existing dynamic array object whose first
element address is \tcode{p}:
If \tcode{pfree} is not a null pointer,
the function calls
\tcode{(*pfree)(p)}.
Otherwise, it evaluates the expression \tcode{delete[]p}.
\pnum
If
\tcode{strmode \& dynamic == 0},
or if
\tcode{strmode \& frozen != 0},
the function cannot extend the array (reallocate it with greater length) to make a write position available.
\end{itemdescr}
\indexlibrary{\idxcode{pbackfail}!\idxcode{strstreambuf}}%
\begin{itemdecl}
int_type pbackfail(int_type c = EOF);
\end{itemdecl}
\begin{itemdescr}
\pnum
Puts back the character designated by \tcode{c} to the input
sequence, if possible, in one of three ways:
\begin{itemize}
\item
If
\tcode{c != EOF},
if the input sequence has a putback position available, and if
\tcode{(char)c == gnext[-1]},
assigns
\tcode{gnext - 1}
to \tcode{gnext}.
Returns \tcode{c}.
\item
If
\tcode{c != EOF},
if the input sequence has a putback position available, and if
\tcode{strmode} \& \tcode{constant} is zero,
assigns \tcode{c} to
\tcode{*\dcr{}gnext}.
Returns
\tcode{c}.
\item
If
\tcode{c == EOF}
and if the input sequence has a putback position available,
assigns
\tcode{gnext - 1}
to \tcode{gnext}.
Returns a value other than
\tcode{EOF}.
\end{itemize}
\pnum
Returns
\tcode{EOF}
to indicate failure.
\pnum
\notes
If the function can succeed in more than one of these ways, it is
unspecified which way is chosen.
\indextext{unspecified}%
The function can alter the number of putback
positions available as a result of any call.
\end{itemdescr}
\indexlibrary{\idxcode{underflow}!\idxcode{strstreambuf}}%
\begin{itemdecl}
int_type underflow();
\end{itemdecl}
\begin{itemdescr}
\pnum
\effects
Reads a character from the
\term{input sequence},
if possible, without moving the stream position past it, as follows:
\begin{itemize}
\item
If the input sequence has a read position available, the function
signals success by returning
\tcode{(unsigned char)\brk*gnext}.
\item
Otherwise, if
the current write next pointer \tcode{pnext} is not a null pointer and
is greater than the current read end pointer \tcode{gend},
makes a
\term{read position}
available by
assigning to \tcode{gend} a value greater than \tcode{gnext} and
no greater than \tcode{pnext}.
Returns \tcode{(unsigned char*)gnext}.
\end{itemize}
\pnum
Returns
\tcode{EOF}
to indicate failure.
\pnum
\notes
The function can alter the number of read positions available as a
result of any call.
\end{itemdescr}
\indexlibrary{\idxcode{seekoff}!\idxcode{strstreambuf}}%
\begin{itemdecl}
pos_type seekoff(off_type off, seekdir way, openmode which = in | out);
\end{itemdecl}
\begin{itemdescr}
\pnum
\effects
Alters the stream position within one of the
controlled sequences, if possible, as indicated in Table~\ref{tab:future.seekoff.positioning}.
\begin{libtab2}{\tcode{seekoff} positioning}{tab:future.seekoff.positioning}
{p{2.5in}l}{Conditions}{Result}
\tcode{(which \& ios::in) != 0} &
positions the input sequence \\ \rowsep
\tcode{(which \& ios::out) != 0} &
positions the output sequence \\ \rowsep
\tcode{(which \& (ios::in |}\br
\tcode{ios::out)) == (ios::in |}\br
\tcode{ios::out))} and\br
\tcode{way ==} either\br
\tcode{ios::beg} or\br
\tcode{ios::end} &
positions both the input and the output sequences \\ \rowsep
Otherwise &
the positioning operation fails. \\
\end{libtab2}
\pnum
For a sequence to be positioned, if its next pointer is a null pointer,
the positioning operation fails.
Otherwise, the function determines \tcode{newoff} as indicated in
Table~\ref{tab:future.newoff.values}.
\begin{libtab2}{\tcode{newoff} values}{tab:future.newoff.values}
{p{2.0in}p{2.0in}}{Condition}{\tcode{newoff} Value}
\tcode{way == ios::beg} &
0 \\ \rowsep
\tcode{way == ios::cur} &
the next pointer minus the beginning pointer (\tcode{xnext - xbeg}). \\ \rowsep
\tcode{way == ios::end} &
\tcode{seekhigh} minus the beginning pointer (\tcode{seekhigh - xbeg}). \\
\end{libtab2}
\pnum
If \tcode{(newoff + off) < (seeklow - xbeg)}
or \tcode{(seekhigh - xbeg) < (newoff + off)},
the positioning operation fails.
Otherwise, the function assigns
\tcode{xbeg + newoff + off}
to the next pointer \tcode{xnext}.
\pnum
\returns
\tcode{pos_type(newoff)},
constructed from the resultant offset
\tcode{newoff} (of type
\tcode{off_type}),
that stores the resultant stream position, if possible.
If the positioning operation fails, or
if the constructed object cannot represent the resultant stream position,
the return value is
\tcode{pos_type(off_type(-1))}.
\end{itemdescr}
\indexlibrary{\idxcode{seekpos}!\idxcode{strstreambuf}}%
\begin{itemdecl}
pos_type seekpos(pos_type sp, ios_base::openmode which
= ios_base::in | ios_base::out);
\end{itemdecl}
\begin{itemdescr}
\pnum
\effects
Alters the stream position within one of the
controlled sequences, if possible, to correspond to the
stream position stored in \tcode{sp}
(as described below).
\begin{itemize}
\item
If
\tcode{(which \& ios::in) != 0},
positions the input sequence.
\item
If
\tcode{(which \& ios::out) != 0},
positions the output sequence.
\item
If the function positions neither sequence, the positioning operation fails.
\end{itemize}
\pnum
For a sequence to be positioned, if its next pointer is a null pointer,
the positioning operation fails.
Otherwise, the function determines \tcode{newoff} from
\tcode{sp.offset()}:
\begin{itemize}
\item
If \tcode{newoff} is an invalid stream position,
has a negative value, or
has a value greater than (\tcode{seekhigh} - \tcode{seeklow}),
the positioning operation fails
\item
Otherwise, the function
adds \tcode{newoff} to the beginning pointer \tcode{xbeg} and
stores the result in the next pointer \tcode{xnext}.
\end{itemize}
\pnum
\returns
\tcode{pos_type(newoff)},
constructed from the resultant offset \tcode{newoff}
(of type
\tcode{off_type}),
that stores the resultant stream position, if possible.
If the positioning operation fails, or
if the constructed object cannot represent the resultant stream position,
the return value is
\tcode{pos_type(off_type(-1))}.
\end{itemdescr}
\indexlibrary{\idxcode{setbuf}!\idxcode{strstreambuf}}%
\begin{itemdecl}
streambuf<char>* setbuf(char* s, streamsize n);
\end{itemdecl}
\begin{itemdescr}
\pnum
\effects
Implementation defined, except that
\tcode{setbuf(0, 0)}
has no effect.%
\indexlibrary{\idxcode{setbuf}!\idxcode{streambuf}}
\end{itemdescr}
\rSec2[depr.istrstream]{Class \tcode{istrstream}}
\indexlibrary{\idxcode{istrstream}}%
\begin{codeblock}
namespace std {
class istrstream : public basic_istream<char> {
public:
explicit istrstream(const char* s);
explicit istrstream(char* s);
istrstream(const char* s, streamsize n);
istrstream(char* s, streamsize n);
virtual ~istrstream();
strstreambuf* rdbuf() const;
char* str();
private:
strstreambuf sb; // \expos
};
}
\end{codeblock}
\pnum
The class
\tcode{istrstream}
supports the reading of objects of class
\tcode{strstreambuf}.
It supplies a
\tcode{strstreambuf}
object to control the associated array object.
For the sake of exposition, the maintained data is presented here as:
\begin{itemize}
\item
\tcode{sb}, the \tcode{strstreambuf} object.
\end{itemize}
\rSec3[depr.istrstream.cons]{\tcode{istrstream} constructors}
\indexlibrary{\idxcode{istrstream}!\idxcode{istrstream}}%
\begin{itemdecl}
explicit istrstream(const char* s);
explicit istrstream(char* s);
\end{itemdecl}
\begin{itemdescr}
\pnum
\effects
Constructs an object of class
\tcode{istrstream},
initializing the base class with
\tcode{istream(\&sb)}
and initializing \tcode{sb} with
\tcode{strstreambuf(s,0))}.
\tcode{s} shall designate the first element of an \ntbs.%
\indextext{NTBS}
\end{itemdescr}
\indexlibrary{\idxcode{istrstream}!constructor}%
\begin{itemdecl}
istrstream(const char* s, streamsize n);
\end{itemdecl}
\begin{itemdescr}
\pnum
\effects
Constructs an object of class
\tcode{istrstream},
initializing the base class with
\tcode{istream(\&sb)}
and initializing \tcode{sb} with
\tcode{strstreambuf(s,n))}.
\tcode{s} shall designate the first element of an array whose length is
\tcode{n} elements, and \tcode{n} shall be greater than zero.
\end{itemdescr}
\rSec3[depr.istrstream.members]{Member functions}
\indexlibrary{\idxcode{rdbuf}!\idxcode{istrstream}}%
\begin{itemdecl}
strstreambuf* rdbuf() const;
\end{itemdecl}
\begin{itemdescr}
\pnum
\returns
\tcode{const_cast<strstreambuf*>(\&sb)}.
\end{itemdescr}
\indexlibrary{\idxcode{str}!\idxcode{istrstream}}%
\begin{itemdecl}
char* str();
\end{itemdecl}
\begin{itemdescr}
\pnum
\returns
\tcode{rdbuf()->str()}.
\end{itemdescr}
\rSec2[depr.ostrstream]{Class \tcode{ostrstream}}
\indexlibrary{\idxcode{ostrstream}}%
\begin{codeblock}
namespace std {
class ostrstream : public basic_ostream<char> {
public:
ostrstream();
ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out);