BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bsls.h
Go to the documentation of this file.
1
/// @file bsls.h
2
///
3
///
4
/// @defgroup bsls Package bsls
5
/// @brief Basic Standard Library System utilities (bsls)
6
/// @addtogroup bsl
7
/// @{
8
/// @addtogroup bsls
9
/// @{
10
/// * <a href="#bsls-purpose"> Purpose</a>
11
/// * <a href="#bsls-mnemonic"> Mnemonic </a>
12
/// * <a href="#bsls-description"> Description </a>
13
/// * <a href="#bsls-hierarchical-synopsis"> Hierarchical Synopsis </a>
14
/// * <a href="#bsls-component-synopsis"> Component Synopsis </a>
15
/// * <a href="#bsls-component-overview"> Component Overview </a>
16
/// * <a href="#bsls-ref-bsls_alignedbuffer"> @ref bsls_alignedbuffer </a>
17
/// * <a href="#bsls-ref-bsls_alignment"> @ref bsls_alignment </a>
18
/// * <a href="#bsls-ref-bsls_alignmentfromtype"> @ref bsls_alignmentfromtype </a>
19
/// * <a href="#bsls-ref-bsls_alignmentimp"> @ref bsls_alignmentimp </a>
20
/// * <a href="#bsls-ref-bsls_alignmenttotype"> @ref bsls_alignmenttotype </a>
21
/// * <a href="#bsls-ref-bsls_alignmentutil"> @ref bsls_alignmentutil </a>
22
/// * <a href="#bsls-ref-bsls_annotation"> @ref bsls_annotation </a>
23
/// * <a href="#bsls-ref-bsls_assert"> @ref bsls_assert </a>
24
/// * <a href="#bsls-ref-bsls_asserttest"> @ref bsls_asserttest </a>
25
/// * <a href="#bsls-ref-bsls_asserttestexception"> @ref bsls_asserttestexception </a>
26
/// * <a href="#bsls-ref-bsls_atomic"> @ref bsls_atomic </a>
27
/// * <a href="#bsls-ref-bsls_atomicoperations"> @ref bsls_atomicoperations </a>
28
/// * <a href="#bsls-ref-bsls_blockgrowth"> @ref bsls_blockgrowth </a>
29
/// * <a href="#bsls-ref-bsls_bsltestutil"> @ref bsls_bsltestutil </a>
30
/// * <a href="#bsls-ref-bsls_buildtarget"> @ref bsls_buildtarget </a>
31
/// * <a href="#bsls-ref-bsls_byteorder"> @ref bsls_byteorder </a>
32
/// * <a href="#bsls-ref-bsls_compilerfeatures"> @ref bsls_compilerfeatures </a>
33
/// * <a href="#bsls-ref-bsls_deprecate"> @ref bsls_deprecate </a>
34
/// * <a href="#bsls-ref-bsls_exceptionutil"> @ref bsls_exceptionutil </a>
35
/// * <a href="#bsls-ref-bsls_ident"> @ref bsls_ident </a>
36
/// * <a href="#bsls-ref-bsls_macroincrement"> @ref bsls_macroincrement </a>
37
/// * <a href="#bsls-ref-bsls_nativestd"> @ref bsls_nativestd </a>
38
/// * <a href="#bsls-ref-bsls_nullptr"> @ref bsls_nullptr </a>
39
/// * <a href="#bsls-ref-bsls_objectbuffer"> @ref bsls_objectbuffer </a>
40
/// * <a href="#bsls-ref-bsls_performancehint"> @ref bsls_performancehint </a>
41
/// * <a href="#bsls-ref-bsls_platform"> @ref bsls_platform </a>
42
/// * <a href="#bsls-ref-bsls_protocoltest"> @ref bsls_protocoltest </a>
43
/// * <a href="#bsls-ref-bsls_stopwatch"> @ref bsls_stopwatch </a>
44
/// * <a href="#bsls-ref-bsls_systemclocktype"> @ref bsls_systemclocktype </a>
45
/// * <a href="#bsls-ref-bsls_timeutil"> @ref bsls_timeutil </a>
46
/// * <a href="#bsls-ref-bsls_types"> @ref bsls_types </a>
47
/// * <a href="#bsls-ref-bsls_unspecifiedbool"> @ref bsls_unspecifiedbool </a>
48
/// * <a href="#bsls-ref-bsls_util"> @ref bsls_util </a>
49
/// * <a href="#bsls-movable-and-forwarding-reference-macros-and-utilities"> Movable and Forwarding Reference Macros And Utilities </a>
50
/// * <a href="#bsls-summary"> Summary </a>
51
/// * <a href="#bsls-perfect-forwarding"> Perfect Forwarding </a>
52
/// * <a href="#bsls-short-complete-example"> Short Complete Example </a>
53
/// * <a href="#bsls-movable-reference-to-templated-type"> Movable Reference to Templated Type </a>
54
/// * <a href="#bsls-forwarding-parameters-through-many-layers-efficiently"> Forwarding Parameters Through Many Layers Efficiently </a>
55
///
56
/// # Purpose {#bsls-purpose}
57
/// Provide system-level utilities for 'bsl'.
58
///
59
/// # Mnemonic {#bsls-mnemonic}
60
/// Basic Standard Library System utilities (bsls)
61
///
62
/// # Description {#bsls-description}
63
/// The 'bsls' package provides a variety of system utilities for use
64
/// by the 'bsl' library. These utilities include:
65
///
66
/// * Various buffer types with different alignment properties.
67
/// * Uniform exception handling, even for non-exception build targets.
68
/// * A platform-dependent 64-bit integer type.
69
/// * Platform-identification routines.
70
/// * A timer component, and access to system time facilities.
71
///
72
/// Note that the above list is not meant to be exhaustive. The sections below
73
/// provide more information about the individual components.
74
///
75
/// ## Hierarchical Synopsis {#bsls-hierarchical-synopsis}
76
///
77
/// The 'bsls' package currently has 87 components having 16 levels of physical
78
/// dependency. The list below shows the hierarchical ordering of the components.
79
/// The order of components within each level is not architecturally significant,
80
/// just alphabetical.
81
/// @code
82
/// 16. bsls_byteorder
83
///
84
/// 15. bsls_alignedbuffer
85
/// bsls_alignment
86
/// bsls_byteorderutil
87
/// bsls_platformutil !DEPRECATED!
88
/// bsls_systemtime
89
///
90
/// 14. bsls_alignmentutil
91
/// bsls_bslexceptionutil
92
/// bsls_fuzztest
93
/// bsls_fuzztest_testutil !PRIVATE!
94
/// bsls_stopwatch
95
/// bsls_timeinterval
96
///
97
/// 13. bsls_asserttest
98
/// bsls_byteorderutil_impl !PRIVATE!
99
/// bsls_exceptionutil
100
/// bsls_fuzztestpreconditionexception
101
/// bsls_nameof
102
/// bsls_outputredirector
103
/// bsls_preconditions
104
/// bsls_spinlock
105
/// bsls_timeutil
106
///
107
/// 12. bsls_assert
108
///
109
/// 11. bsls_review
110
///
111
/// 10. bsls_atomic
112
/// bsls_bslonce
113
/// bsls_log
114
///
115
/// 9. bsls_atomicoperations
116
///
117
/// 8. bsls_atomicoperations_sparc32_sun_cc !PRIVATE!
118
/// bsls_atomicoperations_sparc64_sun_cc !PRIVATE!
119
/// bsls_bsllock
120
/// bsls_objectbuffer
121
/// bsls_protocoltest
122
///
123
/// 7. bsls_alignmentfromtype
124
/// bsls_assertimputil
125
/// bsls_asserttestexception
126
/// bsls_atomicoperations_sparc_sun_cc_default !PRIVATE!
127
/// bsls_bsllockimpl_win32 !PRIVATE!
128
/// bsls_cpp11 !DEPRECATED!
129
/// bsls_libraryfeatures
130
/// bsls_pointercastutil
131
/// bsls_util
132
///
133
/// 6. bsls_alignmenttotype
134
/// bsls_annotation !DEPRECATED!
135
/// bsls_atomicoperations_powerpc32_aix_xlc !PRIVATE!
136
/// bsls_atomicoperations_powerpc64_aix_xlc !PRIVATE!
137
/// bsls_consteval
138
/// bsls_keyword
139
/// bsls_nullptr
140
/// bsls_performancehint
141
///
142
/// 5. bsls_atomicoperations_all_all_clangintrinsics !PRIVATE!
143
/// bsls_atomicoperations_all_all_gccintrinsics !PRIVATE!
144
/// bsls_atomicoperations_arm32_win_msvc !PRIVATE!
145
/// bsls_atomicoperations_arm64_win_msvc !PRIVATE!
146
/// bsls_atomicoperations_arm_all_gcc !PRIVATE!
147
/// bsls_atomicoperations_powerpc_aix_xlc_default !PRIVATE!
148
/// bsls_atomicoperations_powerpc_all_gcc !PRIVATE!
149
/// bsls_atomicoperations_x64_all_gcc !PRIVATE!
150
/// bsls_atomicoperations_x64_win_msvc !PRIVATE!
151
/// bsls_atomicoperations_x86_all_gcc !PRIVATE!
152
/// bsls_atomicoperations_x86_win_msvc !PRIVATE!
153
/// bsls_bsllockimpl_pthread !PRIVATE!
154
/// bsls_compilerfeatures
155
///
156
/// 4. bsls_assert_macroreset !PRIVATE!
157
/// bsls_asserttest_macroreset !PRIVATE!
158
/// bsls_atomicoperations_default !PRIVATE!
159
/// bsls_buildtarget
160
/// bsls_int64 !DEPRECATED!
161
/// bsls_logseverity
162
/// bsls_review_macroreset !PRIVATE!
163
/// bsls_stackaddressutil
164
/// bsls_systemclocktype
165
/// bsls_unspecifiedbool
166
///
167
/// 3. bsls_alignmentimp
168
/// bsls_bslsourcenameparserutil
169
/// bsls_bsltestutil
170
/// bsls_linkcoercion
171
/// bsls_stackaddressutil_plinktimestamp !PRIVATE!
172
/// bsls_types
173
///
174
/// 2. bsls_blockgrowth
175
/// bsls_bsldeprecationinformation
176
/// bsls_macroincrement
177
/// bsls_macrorepeat
178
/// bsls_nativestd !DEPRECATED!
179
/// bsls_platform
180
///
181
/// 1. bsls_deprecate !DEPRECATED!
182
/// bsls_deprecatefeature
183
/// bsls_ident
184
/// @endcode
185
///
186
/// ## Component Synopsis {#bsls-component-synopsis}
187
///
188
/// @ref bsls_alignedbuffer :
189
/// Provide raw buffers with user-specified size and alignment.
190
///
191
/// @ref bsls_alignment :
192
/// Provide a namespace for enumerating memory alignment strategies.
193
///
194
/// @ref bsls_alignmentfromtype :
195
/// Provide a meta-function that maps a `TYPE` to its alignment.
196
///
197
/// @ref bsls_alignmentimp :
198
/// Provide implementation meta-functions for alignment computation.
199
///
200
/// @ref bsls_alignmenttotype :
201
/// Provide a meta-function mapping an `ALIGNMENT` to a primitive type.
202
///
203
/// @ref bsls_alignmentutil :
204
/// Provide constants, types, and operations related to alignment.
205
///
206
/// @ref bsls_annotation : !DEPRECATED!
207
/// Provide support for compiler annotations for compile-time safety.
208
///
209
/// @ref bsls_assert :
210
/// Provide build-specific, runtime-configurable assertion macros.
211
///
212
/// @ref bsls_assert_macroreset : !PRIVATE!
213
/// Undefine all macros from `bsls_assert.h` and `bsls_review.h`.
214
///
215
/// @ref bsls_assertimputil :
216
/// Provide utilities to implement @ref bsls_assert and @ref bsls_review .
217
///
218
/// @ref bsls_asserttest :
219
/// Provide a test facility for assertion macros.
220
///
221
/// @ref bsls_asserttest_macroreset : !PRIVATE!
222
/// Undefine macros related to `bsls_asserttest.h`.
223
///
224
/// @ref bsls_asserttestexception :
225
/// Provide an exception type to support testing for failed assertions.
226
///
227
/// @ref bsls_atomic :
228
/// Provide types with atomic operations.
229
///
230
/// @ref bsls_atomicoperations :
231
/// Provide platform-independent atomic operations.
232
///
233
/// @ref bsls_atomicoperations_all_all_clangintrinsics : !PRIVATE!
234
/// Implement atomic operations using clang `__c11_atomic_*` intrinsics
235
///
236
/// @ref bsls_atomicoperations_all_all_gccintrinsics : !PRIVATE!
237
/// Implement atomic operations using gcc `__atomic_*` intrinsics.
238
///
239
/// @ref bsls_atomicoperations_arm32_win_msvc : !PRIVATE!
240
/// Provide implementations of atomic operations for arm32/MSVC/Win.
241
///
242
/// @ref bsls_atomicoperations_arm64_win_msvc : !PRIVATE!
243
/// Provide implementations of atomic operations for arm64/MSVC/Win.
244
///
245
/// @ref bsls_atomicoperations_arm_all_gcc : !PRIVATE!
246
/// Provide implementations of atomic operations for ARM/GCC.
247
///
248
/// @ref bsls_atomicoperations_default : !PRIVATE!
249
/// Provide default implementation for atomic operations.
250
///
251
/// @ref bsls_atomicoperations_powerpc32_aix_xlc : !PRIVATE!
252
/// Provide implementations of atomic operations for PowerPC/AIX-32bit.
253
///
254
/// @ref bsls_atomicoperations_powerpc64_aix_xlc : !PRIVATE!
255
/// Provide implementations of atomic operations for PowerPC/AIX-64bit.
256
///
257
/// @ref bsls_atomicoperations_powerpc_aix_xlc_default : !PRIVATE!
258
/// Provide default base implementations of atomics for PowerPC/AIX.
259
///
260
/// @ref bsls_atomicoperations_powerpc_all_gcc : !PRIVATE!
261
/// Provide implementations of atomic operations for gcc on PowerPC
262
///
263
/// @ref bsls_atomicoperations_sparc32_sun_cc : !PRIVATE!
264
/// Provide implementations of atomic operations for Sparc/Sun (32bit).
265
///
266
/// @ref bsls_atomicoperations_sparc64_sun_cc : !PRIVATE!
267
/// Provide implementations of atomic operations for Sparc/Sun (64bit).
268
///
269
/// @ref bsls_atomicoperations_sparc_sun_cc_default : !PRIVATE!
270
/// Provide default base implementations of atomics for Sparc/Sun.
271
///
272
/// @ref bsls_atomicoperations_x64_all_gcc : !PRIVATE!
273
/// Provide implementations of atomic operations for X86_64/GCC.
274
///
275
/// @ref bsls_atomicoperations_x64_win_msvc : !PRIVATE!
276
/// Provide implementations of atomic operations for X86_64/MSVC/Win64.
277
///
278
/// @ref bsls_atomicoperations_x86_all_gcc : !PRIVATE!
279
/// Provide implementations of atomic operations for X86/GCC.
280
///
281
/// @ref bsls_atomicoperations_x86_win_msvc : !PRIVATE!
282
/// Provide implementations of atomic operations for X86/MSVC/Windows.
283
///
284
/// @ref bsls_blockgrowth :
285
/// Provide a namespace for memory block growth strategies.
286
///
287
/// @ref bsls_bsldeprecationinformation :
288
/// Provide a macro to control `bsl` deprecations by release version.
289
///
290
/// @ref bsls_bslexceptionutil :
291
/// Provide functions for use in `bsl` that throw standard exceptions.
292
///
293
/// @ref bsls_bsllock :
294
/// Provide a platform-independent mutex for use below `bslmt`.
295
///
296
/// @ref bsls_bsllockimpl_pthread : !PRIVATE!
297
/// Provide a mutex for use below `bslmt`.
298
///
299
/// @ref bsls_bsllockimpl_win32 : !PRIVATE!
300
/// Provide a mutex for use below `bslmt` for windows platform.
301
///
302
/// @ref bsls_bslonce :
303
/// Provide BSL a thread-safe way to execute code once per process.
304
///
305
/// @ref bsls_bslsourcenameparserutil :
306
/// Provide low-level functions for parsing source file names.
307
///
308
/// @ref bsls_bsltestutil :
309
/// Provide test utilities for `bsl` that do not use <iostream>.
310
///
311
/// @ref bsls_buildtarget :
312
/// Provide build-target information in object files.
313
///
314
/// @ref bsls_byteorder :
315
/// Provide byte-order manipulation macros.
316
///
317
/// @ref bsls_byteorderutil :
318
/// Provide byte-order swapping functions.
319
///
320
/// @ref bsls_byteorderutil_impl : !PRIVATE!
321
/// Provide implementation of byte-order manipulation functions.
322
///
323
/// @ref bsls_compilerfeatures :
324
/// Provide macros to identify compiler support for C++11 features.
325
///
326
/// @ref bsls_consteval :
327
/// Provide macros related to compile-time evaluation.
328
///
329
/// @ref bsls_cpp11 : !DEPRECATED!
330
/// Provide macros for C++11 forward compatibility.
331
///
332
/// @ref bsls_deprecate : !DEPRECATED!
333
/// Provide machinery to deprecate interfaces on a per-version basis.
334
///
335
/// @ref bsls_deprecatefeature :
336
/// Provide machinery to deprecate entities in C++ code.
337
///
338
/// @ref bsls_exceptionutil :
339
/// Provide simplified exception constructs for non-exception builds.
340
///
341
/// @ref bsls_fuzztest :
342
/// Provide macros for use in fuzz testing narrow-contract functions.
343
///
344
/// @ref bsls_fuzztest_testutil : !PRIVATE!
345
/// Provide utilities for @ref bsls_fuzztest component.
346
///
347
/// @ref bsls_fuzztestpreconditionexception :
348
/// Provide an exception type for handling failed preconditions.
349
///
350
/// @ref bsls_ident :
351
/// Provide macros for inserting SCM Ids into source files.
352
///
353
/// @ref bsls_int64 : !DEPRECATED!
354
/// Provide namespace for platform-dependent 64-bit integer types.
355
///
356
/// @ref bsls_keyword :
357
/// Provide macros for forward language dialect compatibility.
358
///
359
/// @ref bsls_libraryfeatures :
360
/// Provide macros to identify native standard library features.
361
///
362
/// @ref bsls_linkcoercion :
363
/// Provide a way to force a link-time dependency into an object.
364
///
365
/// 'bsls_log':
366
/// Provide a namespace for low-level logging functions.
367
///
368
/// @ref bsls_logseverity :
369
/// Enumerate a set of logging severity levels.
370
///
371
/// @ref bsls_macroincrement :
372
/// Provide a macro to increment preprocessor numbers.
373
///
374
/// @ref bsls_macrorepeat :
375
/// repeat a macro invocation with different numeric arguments.
376
///
377
/// @ref bsls_nameof :
378
/// Provide a `NameOf` type for displaying template type at run-time.
379
///
380
/// @ref bsls_nativestd : !DEPRECATED!
381
/// Define the namespace `native_std` as an alias for `::std`.
382
///
383
/// @ref bsls_nullptr :
384
/// Provide a distinct type for null pointer literals.
385
///
386
/// @ref bsls_objectbuffer :
387
/// Provide raw buffer with size and alignment of user-specified type.
388
///
389
/// @ref bsls_outputredirector :
390
/// Provide a means for test drivers to redirect and inspect output.
391
///
392
/// @ref bsls_performancehint :
393
/// Provide performance hints for code optimization.
394
///
395
/// @ref bsls_platform :
396
/// Provide compile-time support for platform/attribute identification.
397
///
398
/// @ref bsls_platformutil : !DEPRECATED!
399
/// Provide consistent interface for platform-dependent functionality.
400
///
401
/// @ref bsls_pointercastutil :
402
/// Provide function to cast between function and data pointers.
403
///
404
/// @ref bsls_preconditions :
405
/// Provide macros for use in fuzz testing narrow contract functions.
406
///
407
/// @ref bsls_protocoltest :
408
/// Provide classes and macros for testing abstract protocols.
409
///
410
/// @ref bsls_review :
411
/// Provide assertion macros to safely identify contract violations.
412
///
413
/// @ref bsls_review_macroreset : !PRIVATE!
414
/// Test driver utility to undefine all macros from `bsls_review.h`.
415
///
416
/// @ref bsls_spinlock :
417
/// Provide a spin lock.
418
///
419
/// @ref bsls_stackaddressutil :
420
/// Provide a utility for obtaining return addresses from the stack.
421
///
422
/// @ref bsls_stackaddressutil_plinktimestamp : !PRIVATE!
423
/// Declare and weakly define a @ref plink_timestamp___ global variable.
424
///
425
/// @ref bsls_stopwatch :
426
/// Provide access to user, system, and wall times of current process.
427
///
428
/// @ref bsls_systemclocktype :
429
/// Enumerate the set of system clock types.
430
///
431
/// @ref bsls_systemtime :
432
/// Provide utilities to retrieve the system time.
433
///
434
/// @ref bsls_timeinterval :
435
/// Provide a representation of a time interval.
436
///
437
/// @ref bsls_timeutil :
438
/// Provide a platform-neutral functional interface to system clocks.
439
///
440
/// @ref bsls_types :
441
/// Provide a consistent interface for platform-dependent types.
442
///
443
/// @ref bsls_unspecifiedbool :
444
/// Provide a class supporting the `unspecified bool` idiom.
445
///
446
/// @ref bsls_util :
447
/// Provide essential, low-level support for portable generic code.
448
///
449
/// ## Component Overview {#bsls-component-overview}
450
///
451
/// This section provides a brief introduction to some of the components in the
452
/// 'bsls' package. See the documentation in each component for full details.
453
///
454
/// ### @ref bsls_alignedbuffer {#bsls-ref-bsls_alignedbuffer}
455
///
456
/// The @ref bsls_alignedbuffer component provides a parameterized buffer type with
457
/// a user-specified compile-time size and user-specified alignment. Typically,
458
/// such a type is used in situations where it is desirable to allocate a block of
459
/// properly-aligned raw memory from somewhere other than the heap, e.g., on the
460
/// stack or within an aggregate object, including within a union. It is a
461
/// convenient way to create a small heap from which one or more objects are
462
/// allocated at run-time.
463
///
464
/// ### @ref bsls_alignment {#bsls-ref-bsls_alignment}
465
///
466
/// The @ref bsls_alignment component computes (at compile-time) platform-dependent
467
/// alignment information. This component also provides a namespace for a suite
468
/// of compile-time constants and pure procedures that yield platform-dependent
469
/// alignment information for primitive and user-defined types, including the
470
/// maximum alignment for any type and the smallest fundamental type requiring
471
/// maximum alignment. These functions, used in conjunction, are especially
472
/// useful for creating pools and allocators that rely on efficient alignment.
473
///
474
/// ### @ref bsls_alignmentfromtype {#bsls-ref-bsls_alignmentfromtype}
475
///
476
/// The @ref bsls_alignmentfromtype component provides a meta-function that
477
/// provides the alignment for a 'TYPE' template parameter.
478
///
479
/// ### @ref bsls_alignmentimp {#bsls-ref-bsls_alignmentimp}
480
///
481
/// The @ref bsls_alignmentimp component provides a suite of template
482
/// meta-functions that can be used to compute (at compile-time) various
483
/// platform-dependent alignment information.
484
///
485
/// ### @ref bsls_alignmenttotype {#bsls-ref-bsls_alignmenttotype}
486
///
487
/// The @ref bsls_alignmenttotype component provides a meta-function that defines a
488
/// primitive type with an alignment matching a 'ALIGNMENT' template parameter.
489
///
490
/// ### @ref bsls_alignmentutil {#bsls-ref-bsls_alignmentutil}
491
///
492
/// The @ref bsls_alignmentutil component provides a suite of template
493
/// meta-functions that can be used to compute (at compile-time) various
494
/// platform-dependent alignment information.
495
///
496
/// ### @ref bsls_annotation {#bsls-ref-bsls_annotation}
497
///
498
/// The @ref bsls_annotation component provides a suite of preprocessor macros that
499
/// define compiler-specific compile-time annotations.
500
///
501
/// ### @ref bsls_assert {#bsls-ref-bsls_assert}
502
///
503
/// The @ref bsls_assert component provides a set of "assert-like" macros to
504
/// implement a compile-time-selectable and run-time-configurable "defensive" or
505
/// "safe" mode. It also provides a suite of "assert-failure handler" methods
506
/// suitable for runtime loading into the macros, via also provided methods.
507
/// Users may supply their own handler methods matching the proper signature. To
508
/// allow the user more flexibility in changing handlers during program execution,
509
/// this component also provides a scoped guard that allows safe, temporary
510
/// changing of the failure handler in a limited scope.
511
///
512
/// ### @ref bsls_asserttest {#bsls-ref-bsls_asserttest}
513
///
514
/// The @ref bsls_asserttest component provides a facility to test that
515
/// 'BSLS_ASSERT_*' macros are used as intended, in the appropriate build modes,
516
/// and have the expected effects.
517
///
518
/// ### @ref bsls_asserttestexception {#bsls-ref-bsls_asserttestexception}
519
///
520
/// The @ref bsls_asserttestexception component implements an exception class,
521
/// 'bsls::AssertTestException', that provides a mechanism to convey context
522
/// information from a failing assertion to a test handler.
523
///
524
/// ### @ref bsls_atomic {#bsls-ref-bsls_atomic}
525
///
526
/// The @ref bsls_atomic component provides classes with atomic operations for
527
/// 'int', 'Int64', and pointer types.
528
///
529
/// ### @ref bsls_atomicoperations {#bsls-ref-bsls_atomicoperations}
530
///
531
/// The @ref bsls_atomicoperations component provides a set of platform-independent
532
/// atomic operations for fundamental data types, such as 32-bit and 64-bit
533
/// integer and pointer.
534
///
535
/// ### @ref bsls_blockgrowth {#bsls-ref-bsls_blockgrowth}
536
///
537
/// The @ref bsls_blockgrowth component enumerates the supported block growth
538
/// strategies.
539
///
540
/// ### @ref bsls_bsltestutil {#bsls-ref-bsls_bsltestutil}
541
///
542
/// The @ref bsls_bsltestutil component provides the standard printing macros used
543
/// in BDE-style test drivers.
544
///
545
/// ### @ref bsls_buildtarget {#bsls-ref-bsls_buildtarget}
546
///
547
/// The @ref bsls_buildtarget component defines types and runtime constants for
548
/// identifying the build target information (usually specified to the compiler
549
/// via a set of 'BDE_BUILD_*' macros). This is mostly useful for retrieving such
550
/// information from a linkable or executable binary.
551
///
552
/// ### @ref bsls_byteorder {#bsls-ref-bsls_byteorder}
553
///
554
/// The @ref bsls_byteorder component provides a set host-to-network and
555
/// network-to-host byte-order manipulation macros.
556
///
557
/// ### @ref bsls_compilerfeatures {#bsls-ref-bsls_compilerfeatures}
558
///
559
/// The @ref bsls_compilerfeatures component provides a suite of preprocessor
560
/// macros to identify compiler-specific support of language features that may not
561
/// be available on all compilers in use across an organization.
562
///
563
/// ### @ref bsls_deprecate {#bsls-ref-bsls_deprecate}
564
///
565
/// The @ref bsls_deprecate component provides a suite of macros to control (on a
566
/// per-version, per-UOR basis) the deprecation of functions, user-defined types,
567
/// and 'typedef's.
568
///
569
/// ### @ref bsls_exceptionutil {#bsls-ref-bsls_exceptionutil}
570
///
571
/// The @ref bsls_exceptionutil component provides macros to replace 'try', 'throw'
572
/// and 'catch'. These macros expand to normal exception constructs when
573
/// exceptions are enabled and to reasonable alternatives (usually no-ops) when
574
/// exceptions are disabled, allowing code that uses 'try', 'throw' and 'catch'
575
/// constructs to compile even if exceptions are disabled using a compiler switch.
576
///
577
/// ### @ref bsls_ident {#bsls-ref-bsls_ident}
578
///
579
/// The @ref bsls_ident component provides macros for inserting SCM (Source Control
580
/// Management) Ids into source files.
581
///
582
/// ### @ref bsls_macroincrement {#bsls-ref-bsls_macroincrement}
583
///
584
/// The @ref bsls_macroincrement component provides a macro,
585
/// 'BSLS_MACROINCREMENT(NUMBER)', that produces the preprocessor number equal to
586
/// the number succeeding the supplied argument.
587
///
588
/// ### @ref bsls_nativestd {#bsls-ref-bsls_nativestd}
589
///
590
/// The @ref bsls_nativestd component defines a namespace alias, 'native_std', that
591
/// serves as an alias for the 'std' namespace.
592
///
593
/// ### @ref bsls_nullptr {#bsls-ref-bsls_nullptr}
594
///
595
/// The @ref bsls_nullptr component provides a limited emulation of the C++11 type,
596
/// 'std::nullptr_t', which can be used as a function parameter type to create an
597
/// overload set where null pointer literals are handled specially.
598
///
599
/// ### @ref bsls_objectbuffer {#bsls-ref-bsls_objectbuffer}
600
///
601
/// The @ref bsls_objectbuffer component provides a parameterized buffer type,
602
/// 'bsls_ObjectBuffer', which is compile-time sized and aligned to hold a
603
/// specified object type. Defining a 'bsls_ObjectBuffer<T>' object does not
604
/// cause the constructor for 'T' to be called. Similarly, destroying the object
605
/// buffer does not call the destructor for 'T'. Typically, a 'bsls_ObjectBuffer'
606
/// is used in situations where efficient (e.g., stack-based) storage is required
607
/// but where straightforward initialization or destruction of an object is not
608
/// possible. It can also be used to create a 'union' containing non-POD element
609
/// types.
610
///
611
/// ### @ref bsls_performancehint {#bsls-ref-bsls_performancehint}
612
///
613
/// The @ref bsls_performancehint component provides performance hints for the
614
/// compiler or hardware.
615
///
616
/// ### @ref bsls_platform {#bsls-ref-bsls_platform}
617
///
618
/// The @ref bsls_platform component defines preprocessor macros that identify and
619
/// describe platform-specific attributes (at compile time). These attributes
620
/// consist of the types and versions of operating system, processor(s), and
621
/// compiler that comprise the platform.
622
///
623
/// ### @ref bsls_protocoltest {#bsls-ref-bsls_protocoltest}
624
///
625
/// The @ref bsls_protocoltest component provides classes and macros for testing
626
/// abstract protocols.
627
///
628
/// ### @ref bsls_stopwatch {#bsls-ref-bsls_stopwatch}
629
///
630
/// The @ref bsls_stopwatch component implements a real-time (system clock)
631
/// interval timer. A 'bsls_Stopwatch' object can accumulate and return only one
632
/// interval at a time, but may be started and stopped repeatedly without being
633
/// reset, so the elapsed time "interval" accumulated by a single object may be
634
/// from multiple, discontinuous segments of time. The non-negative total
635
/// accumulated time (in seconds) is available as a 'double' value.
636
///
637
/// ### @ref bsls_systemclocktype {#bsls-ref-bsls_systemclocktype}
638
///
639
/// The @ref bsls_systemclocktype component provides a namespace for the 'enum'
640
/// type 'bsls::SystemClockType::Enum', which enumerates the set of system clock
641
/// types. A 'bsls::SystemClockType' is particularly important when providing
642
/// time-out values to synchronization methods where those time-outs must be
643
/// consistent in environments where the system clocks may be changed.
644
///
645
/// ### @ref bsls_timeutil {#bsls-ref-bsls_timeutil}
646
///
647
/// The @ref bsls_timeutil component provides a set of platform-neutral pure
648
/// procedures to access real-time system clock functionality. High-resolution
649
/// time functions intended for interval-timing return an interval in nanoseconds
650
/// (1 nsec = 1E-9 sec) as a 64-bit integer.
651
///
652
/// ### @ref bsls_types {#bsls-ref-bsls_types}
653
///
654
/// The @ref bsls_types component provides a namespace for a set of 'typedef's that
655
/// provide a stable, portable interface to platform-dependent types.
656
///
657
/// ### @ref bsls_unspecifiedbool {#bsls-ref-bsls_unspecifiedbool}
658
///
659
/// The @ref bsls_unspecifiedbool component provides a class template that can be
660
/// used to manufacture an "unspecified boolean type" that is distinct for each
661
/// class that instantiates it. *Not* for use outside the 'bsl' package.
662
///
663
/// ### @ref bsls_util {#bsls-ref-bsls_util}
664
///
665
/// The @ref bsls_util component provides pure functions that supply essential
666
/// low-level support for implementing portable generic facilities such as might
667
/// be found in the C++ standard library.
668
///
669
/// ## Movable and Forwarding Reference Macros And Utilities {#bsls-movable-and-forwarding-reference-macros-and-utilities}
670
///
671
/// Modern C++ (C++11 and later) introduces the concepts of moving and forwarding
672
/// function arguments. The BDE library provides facilities to replicate these
673
/// features in C++03, and also allow writing code in a way that the same code can
674
/// be compiled in both C++03 and in modern C++ (where the features are natively
675
/// supported). This document describes which of these BDE facilities to use in
676
/// which contexts. This section assumes familiarity with movable types and the
677
/// use of @ref bslmf_movableref for move semantics in C++03-compatible code.
678
///
679
/// ### Summary {#bsls-summary}
680
///
681
/// Four utilities are to be described and their correct usage explained, and
682
/// they are summarized in the following table. The term "forwarding" refers to
683
/// passing a variable recieved as an argument in one function to another
684
/// function, generally without altering it. The term "perfect forwarding"
685
/// refers to forwarding not only the value that the argument represents, but
686
/// also characterstics of the argument such as cv-qualifications, and whether it
687
/// is an rvalue or an lvalue.
688
///
689
/// 'BSLS_COMPILERFEATURES_FORWARD_REF(T)':
690
/// Used to declare a function template argument of type 'T' that is to be
691
/// perfect-forwarded.
692
/// 'BSLS_COMPILERFEATURES_FORWARD(T, V)':
693
/// Used to perfect-forward a function template argument, 'V', of type 'T'.
694
/// 'BSLMF_MOVABLEREF_DEDUCE(T)':
695
/// Used to deduce the type 'T' of a templated rvalue reference argument.
696
/// 'bslmf::ForwardingType' and 'bslmf::ForwardingRefType':
697
/// Used to forward arguments through layers of nested calls efficiently.
698
///
699
/// The following sections explain in detail the contexts in which the above
700
/// macros and types are used.
701
///
702
/// ### Perfect Forwarding {#bsls-perfect-forwarding}
703
///
704
/// In modern C++, function parameters marked with double ampersands ('&&') can
705
/// either be movable references or forwarding references. The difference is
706
/// whether the type of the parameter excluding the '&&' is a template type of the
707
/// function (templates are forwarding references, non-templates are movable
708
/// references). Forwarding references are lvalues that can bind to either an
709
/// lvalue reference or an rvalue reference, and can be converted back to the
710
/// original reference type with 'bsl::forward'. The BDE library achieves this
711
/// effect in C++03 with two macros, 'BSLS_COMPILERFEATURES_FORWARD_REF' and
712
/// 'BSLS_COMPILERFEATURES_FORWARD'.
713
///
714
/// 'BSLS_COMPILERFEATURES_FORWARD_REF(T)' is used to declare a function template
715
/// argument of type 'T' that is to be perfect-forwarded.
716
///
717
/// 'BSLS_COMPILERFEATURES_FORWARD(T, V)' is used to perfect-forward a function
718
/// template argument, 'V', of type 'T'.
719
///
720
/// For example:
721
/// @code
722
/// template <class T>
723
/// void deduce(BSLS_COMPILERFEATURES_FORWARD_REF(T) t) // Forwarding reference
724
/// {
725
/// Forwarded tt(BSLS_COMPILERFEATURES_FORWARD(T, t)); // Perfect forwarding
726
/// }
727
/// @endcode
728
///
729
/// ### Short Complete Example {#bsls-short-complete-example}
730
///
731
/// The following code will compile and run in any BDE-supported version of C++.
732
/// @code
733
/// #include <bslmf_movableref.h>
734
/// #include <bslmf_util.h>
735
///
736
/// #include <bsls_compilerfeatures.h>
737
///
738
/// #include <bsl_iostream.h>
739
/// #include <bsl_utility.h>
740
///
741
/// using namespace BloombergLP;
742
///
743
/// struct Forwarded;
744
///
745
/// // =====================================================================
746
/// // Parameter 't' of function 'deduce' is a forwarding reference that is
747
/// // forwarded to the constructor of local 'tt' to demonstrate being moved
748
/// // or copied, depending on the type of the parameter passed.
749
/// // =====================================================================
750
/// template <class T>
751
/// void deduce(BSLS_COMPILERFEATURES_FORWARD_REF(T) t) // Forwarding reference
752
/// {
753
/// Forwarded tt(BSLS_COMPILERFEATURES_FORWARD(T, t)); // Perfect forwarding
754
/// }
755
///
756
/// struct Forwarded
757
/// {
758
/// // A class to demonstrate whether moving or copying is taking place
759
/// Forwarded(){bsl::cout << "Default\n";}
760
/// Forwarded(const Forwarded&){bsl::cout << "Copy\n";}
761
/// Forwarded(bslmf::MovableRef<Forwarded>){bsl::cout << "Move\n";}
762
/// };
763
///
764
/// int main()
765
/// {
766
/// Forwarded f;
767
/// deduce(f); // Parameter is lvalue reference
768
/// deduce(bslmf::MovableRefUtil::move(f)); // Parameter is rvalue reference
769
/// }
770
/// @endcode
771
/// This program should output the following.
772
/// @code
773
/// Default
774
/// Copy
775
/// Move
776
/// @endcode
777
///
778
/// ### Movable Reference to Templated Type {#bsls-movable-reference-to-templated-type}
779
///
780
/// 'bslmf::MovableRef' is a template facility that provides move semantics in
781
/// C++03. One common issue with 'MovableRef<T>' is its use in a context where
782
/// 'T' itself is a template parameter: the compiler will be unable to deduce the
783
/// type of 'T' in C++11 (or later) as one would expect. For example:
784
/// @code
785
/// template <class T>
786
/// void f(bslmf::MovableRef<A<T> > a);
787
///
788
/// int main()
789
/// {
790
/// A<int> a1;
791
/// f(bslmf::MovableRefUtil::move(a1)); // COMPILE ERROR! Can't deduce 'T'.
792
/// }
793
/// @endcode
794
/// To deduce this type, the macro 'BSLMF_MOVABLEREF_DEDUCE' can be used, for
795
/// example:
796
/// @code
797
/// template <class T>
798
/// void g(BSLMF_MOVABLEREF_DEDUCE(A<T>) a);
799
/// // A function that takes a 'MovableRef<A<T>>'
800
///
801
/// int main()
802
/// {
803
/// A<int> a2;
804
/// g(bslmf::MovableRefUtil::move(a2)); // compiles!
805
/// }
806
/// @endcode
807
/// A real world example can be found in component @ref bdlb_nullablevalue . The
808
/// 'bdlb::NullableValue<TYPE>' constructor taking a movable reference to a
809
/// 'bdlb::NullableValue<BDE_OTHER_TYPE>', with 'BDE_OTHER_TYPE' convertible to
810
/// 'TYPE', uses 'BSLMF_MOVABLEREF_DEDUCE'.
811
/// @code
812
/// template <class BDE_OTHER_TYPE>
813
/// NullableValue(BSLMF_MOVABLEREF_DEDUCE(
814
/// NullableValue<BDE_OTHER_TYPE>) value,
815
/// const allocator_type& allocator,
816
/// typename bsl::enable_if<
817
/// bsl::is_convertible<BDE_OTHER_TYPE, TYPE>::value &&
818
/// !bsl::is_same<bsl::optional<BDE_OTHER_TYPE>, TYPE>::value,
819
/// EnableType>::type = EnableType()); // IMPLICIT
820
/// @endcode
821
///
822
/// ### Forwarding Parameters Through Many Layers Efficiently {#bsls-forwarding-parameters-through-many-layers-efficiently}
823
///
824
/// Generic code that forwards arguments through many layers of metaprogramming
825
/// templates -- e.g., 'bsl::function' and 'bsl::bind' -- can be made more
826
/// efficient through judicious use of 'bslmf::ForwardingRefType'. This allows a
827
/// number of small optimizations. For example, the collapse of array references
828
/// to pointers that are unpacked only once, thereby reducing the number of
829
/// template instantiations of the middle layers. The older
830
/// 'bslmf::ForwardingType' served the same purpose, but is no longer recommended
831
/// since 'bslmf::ForwardingRefType' is simpler to use.
832
///
833
/// *Note:* *The* *component* @ref bslmf_forwardingreftype *is* *a* *complex* *tool*
834
/// *with* *a* *singular* *purpose,* *and* *occassions* *for* *its* *legitimate*
835
/// *use* *are* *rare*.
836
///
837
///
838
/// @}
839
/** @} */
doxygen_input
bde
groups
bsl
bsls
doc
bsls.h
Generated by
1.9.8