BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslmf.h
Go to the documentation of this file.
1/// @file bslmf.h
2///
3///
4/// @defgroup bslmf Package bslmf
5/// @brief Basic Standard Library Meta-Functions (bslmf)
6/// @addtogroup bsl
7/// @{
8/// @addtogroup bslmf
9/// [bslmf]: group__bslmf.html
10/// @{
11///
12/// # Purpose {#bslmf-purpose}
13/// Provide meta-function versions of useful coding constructs.
14///
15/// # Mnemonic {#bslmf-mnemonic}
16/// Basic Standard Library Meta-Functions (bslmf)
17///
18/// # Description {#bslmf-description}
19/// The 'bslmf' package provides meta-function equivalents of certain
20/// useful coding constructs. A meta-function is a template-based, compile-time
21/// construct that behaves like a (runtime) function in that it "evaluates"
22/// arguments and does something different based on the input it is passed (in the
23/// case of templates, the input it is instantiated with). 'bslmf' provides
24/// metafunctions to evaluate (at compile time) constructs such as the following:
25/// an 'if'-statement equivalent, whether a (template) argument is a fundamental
26/// type, whether an argument is an 'enum' type, whether two arguments have the
27/// same type, and more.
28///
29/// The "return value" of that function is generally a compile-time constant under
30/// the form of a nested 'enum' 'VALUE', or in some cases a nested 'Type', or
31/// both. For instance, in order to evaluate whether two types are the same, one
32/// could write a meta-function predicate (evaluating to 0 or 1) as follows:
33/// @code
34/// template <class U, class V>
35/// struct IsSame {
36/// // This 'struct' provides a meta function parameterized by two types 'U'
37/// // and 'V', that takes 'VALUE == 0' unless 'U' and 'V' are the same type,
38/// // in which case it takes 'VALUE == 1'.
39///
40/// // PUBLIC TYPES
41/// enum { VALUE = 0 };
42/// typedef bslmf_MetaInt<VALUE> Type;
43/// };
44///
45/// // SPECIALIZATIONS
46/// template <class T>
47/// struct IsSame<T, T> {
48/// // This specialization of the 'IsSame' meta function is parameterized by
49/// // a single type 'T' and is selected if the two parameters of 'IsSame',
50/// // 'U' and 'V', are both equal to 'T'. It takes 'VALUE == 1'.
51///
52/// // PUBLIC TYPES
53/// enum { VALUE = 1 };
54/// typedef bslmf_MetaInt<VALUE> Type;
55/// };
56/// @endcode
57/// Note the use of a 'bslmf_MetaInt' nested type usually employed for function
58/// dispatching. See the @ref bslmf_issame component-level documentation for a more
59/// thorough usage example.
60///
61/// Other meta-functions don't have a 'VALUE', but apply some type of
62/// transformation (e.g., removing top-level 'const' qualifiers, decaying array
63/// and function types to pointer types). Those usually have a nested 'Type'.
64///
65/// ## Hierarchical Synopsis
66///
67/// The 'bslmf' package currently has 95 components having 21 levels of physical
68/// dependency. The list below shows the hierarchical ordering of the components.
69/// The order of components within each level is not architecturally significant,
70/// just alphabetical.
71/// @code
72/// 21. bslmf_isnothrowswappable
73///
74/// 20. bslmf_isswappable
75///
76/// 19. bslmf_forwardingreftype
77/// bslmf_forwardingtype
78/// bslmf_invokeresult
79/// bslmf_util
80///
81/// 18. bslmf_movableref
82///
83/// 17. bslmf_isbitwisemoveable
84/// bslmf_iscopyconstructible
85/// bslmf_isnothrowmoveconstructible
86///
87/// 16. bslmf_isbitwisecopyable
88///
89/// 15. bslmf_haspointersemantics
90/// bslmf_isbitwiseequalitycomparable
91/// bslmf_istriviallycopyable
92/// bslmf_istriviallydefaultconstructible
93/// bslmf_matcharithmetictype
94/// bslmf_usesallocatorargt
95///
96/// 14. bslmf_detectnestedtrait
97/// bslmf_isenum
98///
99/// 13. bslmf_isaccessiblebaseof
100/// bslmf_isconvertibletoany
101/// bslmf_nestedtraitdeclaration
102/// bslmf_usesallocator
103///
104/// 12. bslmf_isconvertible
105///
106/// 11. bslmf_isfundamental
107///
108/// 10. bslmf_isarithmetic
109///
110/// 9. bslmf_isintegral
111/// bslmf_ismemberpointer
112///
113/// 8. bslmf_addcv
114/// bslmf_ismemberobjectpointer
115///
116/// 7. bslmf_addconst
117/// bslmf_addvolatile
118/// bslmf_decay
119/// bslmf_isempty
120/// bslmf_ismemberfunctionpointer
121/// bslmf_ispolymorphic
122/// bslmf_removepointer
123///
124/// 6. bslmf_isclass
125/// bslmf_isfloatingpoint
126/// bslmf_isfunction
127/// bslmf_ispointer
128/// bslmf_isvoid
129/// bslmf_memberfunctionpointertraits
130/// bslmf_memberpointertraits
131/// bslmf_removecvq
132/// bslmf_removecvref
133///
134/// 5. bslmf_addpointer
135/// bslmf_addreference
136/// bslmf_conjunction
137/// bslmf_disjunction
138/// bslmf_functionpointertraits
139/// bslmf_if !DEPRECATED!
140/// bslmf_makeintegersequence
141/// bslmf_matchanytype
142/// bslmf_metaint !DEPRECATED!
143/// bslmf_negation
144/// bslmf_removecv
145/// bslmf_selecttrait
146///
147/// 4. bslmf_addlvaluereference
148/// bslmf_addrvaluereference
149/// bslmf_arraytopointer
150/// bslmf_conditional
151/// bslmf_enableif
152/// bslmf_integersequence
153/// bslmf_isconst
154/// bslmf_isreference
155/// bslmf_isvolatile
156/// bslmf_nthparameter
157/// bslmf_removeconst
158/// bslmf_removeextent
159/// bslmf_removereference
160/// bslmf_removevolatile
161/// bslmf_resulttype
162/// bslmf_switch
163/// bslmf_tag
164/// bslmf_typeidentity
165/// bslmf_typelist
166///
167/// 3. bslmf_assert
168/// bslmf_isarray
169/// bslmf_islvaluereference
170/// bslmf_ispair
171/// bslmf_isreferencewrapper
172/// bslmf_isrvaluereference
173/// bslmf_issame
174/// bslmf_istransparentpredicate
175/// bslmf_nil
176///
177/// 2. bslmf_allocatorargt
178/// bslmf_booleantestable
179/// bslmf_integralconstant
180/// bslmf_voidtype
181///
182/// 1. bslmf_conjunction_cpp03 !PRIVATE!
183/// bslmf_disjunction_cpp03 !PRIVATE!
184/// bslmf_functionpointertraits_cpp03 !PRIVATE!
185/// bslmf_invokeresult_cpp03 !PRIVATE!
186/// bslmf_nthparameter_cpp03 !PRIVATE!
187/// @endcode
188///
189/// ## Component Synopsis
190///
191/// @ref bslmf_addconst :
192/// Provide a meta-function for adding a top-level `const`-qualifier.
193///
194/// @ref bslmf_addcv :
195/// Provide a meta-function for adding top-level cv-qualifiers.
196///
197/// @ref bslmf_addlvaluereference :
198/// Provide a compile-time type transformation to lvalue reference.
199///
200/// @ref bslmf_addpointer :
201/// Provide meta-function to transform a type to pointer to that type.
202///
203/// @ref bslmf_addreference :
204/// Provide a meta-function for adding "reference-ness" to a type.
205///
206/// @ref bslmf_addrvaluereference :
207/// Provide a compile-time type transformation to rvalue reference.
208///
209/// @ref bslmf_addvolatile :
210/// Provide a meta-function for adding a `volatile`-qualifier.
211///
212/// @ref bslmf_allocatorargt :
213/// Provide a tag type to precede allocator arguments.
214///
215/// @ref bslmf_arraytopointer :
216/// Provide a meta-function to convert array types to pointer types.
217///
218/// @ref bslmf_assert :
219/// Provide a compile-time assertion facility.
220///
221/// @ref bslmf_booleantestable :
222/// Provide an exposition-only concept `boolean-testable`.
223///
224/// @ref bslmf_conditional :
225/// Provide a compile-time conditional type selector.
226///
227/// @ref bslmf_conjunction :
228/// Provide the logical conjunction (AND) for type traits.
229///
230/// 'bslmf_conjunction_cpp03': !PRIVATE!
231/// Provide C++03 implementation for bslmf_conjunction.h
232///
233/// @ref bslmf_decay :
234/// Convert a type to the type used for pass-by-value.
235///
236/// @ref bslmf_detectnestedtrait :
237/// Provide a facility for defining traits and detecting legacy traits.
238///
239/// @ref bslmf_disjunction :
240/// Provide the logical disjunction (OR) for type traits.
241///
242/// 'bslmf_disjunction_cpp03': !PRIVATE!
243/// Provide C++03 implementation for bslmf_disjunction.h
244///
245/// @ref bslmf_enableif :
246/// Provide a utility to set up SFINAE conditions in type deduction.
247///
248/// @ref bslmf_forwardingreftype :
249/// Provide a meta-function for determining a forwarding type.
250///
251/// @ref bslmf_forwardingtype :
252/// Provide a meta-function for determining an optimal forwarding type.
253///
254/// @ref bslmf_functionpointertraits :
255/// Provide a meta-function for determining function pointer traits.
256///
257/// 'bslmf_functionpointertraits_cpp03': !PRIVATE!
258/// Provide C++03 implementation for bslmf_functionpointertraits.h
259///
260/// @ref bslmf_haspointersemantics :
261/// Provide a type trait for pointer semantics.
262///
263/// 'bslmf_if': !DEPRECATED!
264/// Provide a compile-time `if/else` (conditional) meta-function.
265///
266/// @ref bslmf_integersequence :
267/// Provide a template parameter pack of integers.
268///
269/// @ref bslmf_integralconstant :
270/// Provide a mapping from integral constants to unique types.
271///
272/// @ref bslmf_invokeresult :
273/// Determine the result type of an invocable expression.
274///
275/// 'bslmf_invokeresult_cpp03': !PRIVATE!
276/// Provide C++03 implementation for bslmf_invokeresult.h
277///
278/// @ref bslmf_isaccessiblebaseof :
279/// Provide a compile-time check for derived classes.
280///
281/// @ref bslmf_isarithmetic :
282/// Provide a compile-time check for determining arithmetic types.
283///
284/// @ref bslmf_isarray :
285/// Provide a compile-time check for array types.
286///
287/// @ref bslmf_isbitwisecopyable :
288/// Provide a meta-function for determining bitwise copyable types.
289///
290/// @ref bslmf_isbitwiseequalitycomparable :
291/// Provide a type trait for bitwise equality.
292///
293/// @ref bslmf_isbitwisemoveable :
294/// Provide a primitive type trait for bitwise moveable classes.
295///
296/// @ref bslmf_isclass :
297/// Provide a compile-time check for determining class types.
298///
299/// @ref bslmf_isconst :
300/// Provide a compile-time check for `const`-qualified types.
301///
302/// @ref bslmf_isconvertible :
303/// Provide a compile-time check for type conversion.
304///
305/// @ref bslmf_isconvertibletoany :
306/// Provide a compile-time check for types convertible to any type.
307///
308/// @ref bslmf_iscopyconstructible :
309/// Provide a meta-function to report if a type is copy constructible.
310///
311/// @ref bslmf_isempty :
312/// Provide a compile-time check for detecting an empty class type.
313///
314/// @ref bslmf_isenum :
315/// Provide compile-time check for determining enumerated types.
316///
317/// @ref bslmf_isfloatingpoint :
318/// Provide a compile-time check for floating-point types.
319///
320/// @ref bslmf_isfunction :
321/// Provide a compile-time check for determining function types.
322///
323/// @ref bslmf_isfundamental :
324/// Provide a compile-time check for determining fundamental types.
325///
326/// @ref bslmf_isintegral :
327/// Provide a compile-time check for integral types.
328///
329/// @ref bslmf_islvaluereference :
330/// Provide a compile-time check for lvalue reference types.
331///
332/// @ref bslmf_ismemberfunctionpointer :
333/// Provide a compile-time check for member function pointer types.
334///
335/// @ref bslmf_ismemberobjectpointer :
336/// Provide a compile-time check for member object pointer types.
337///
338/// @ref bslmf_ismemberpointer :
339/// Provide a compile-time check for non-static member pointer types.
340///
341/// @ref bslmf_isnothrowmoveconstructible :
342/// Provide metafunction to identify no-throw move-constructible types.
343///
344/// @ref bslmf_isnothrowswappable :
345/// Provide metafunction to identify nothrow swappable types.
346///
347/// @ref bslmf_ispair :
348/// Provide a compile-time check for the bsl::pair type.
349///
350/// @ref bslmf_ispointer :
351/// Provide a compile-time check for pointer types.
352///
353/// @ref bslmf_ispolymorphic :
354/// Provide a compile-time check for determining polymorphic types.
355///
356/// @ref bslmf_isreference :
357/// Provide a meta-function to test reference types.
358///
359/// @ref bslmf_isreferencewrapper :
360/// Provide a trait to detect reference-wrapper specializations.
361///
362/// @ref bslmf_isrvaluereference :
363/// Provide a compile-time check for rvalue reference types.
364///
365/// @ref bslmf_issame :
366/// Provide a meta-function for testing if two types are the same.
367///
368/// @ref bslmf_isswappable :
369/// Provide metafunction to identify swappable types.
370///
371/// @ref bslmf_istransparentpredicate :
372/// Support detection of whether a predicate functor is transparent.
373///
374/// @ref bslmf_istriviallycopyable :
375/// Provide a meta-function for determining trivially copyable types.
376///
377/// @ref bslmf_istriviallydefaultconstructible :
378/// Provide a compile-time check for trivially default-constructible.
379///
380/// @ref bslmf_isvoid :
381/// Provide a compile-time check for `void` types.
382///
383/// @ref bslmf_isvolatile :
384/// Provide a compile-time check for `volatile`-qualified types.
385///
386/// @ref bslmf_makeintegersequence :
387/// Provide a template parameter pack of integers.
388///
389/// @ref bslmf_matchanytype :
390/// Provide a generic type to which any type can be converted.
391///
392/// @ref bslmf_matcharithmetictype :
393/// Provide a class supporting "do-the-right-thing clause" dispatch.
394///
395/// @ref bslmf_memberfunctionpointertraits :
396/// Provide meta-functions to detect member function pointer traits.
397///
398/// @ref bslmf_memberpointertraits :
399/// Provide meta-function to detect pointer to member traits.
400///
401/// @ref bslmf_metaint : !DEPRECATED!
402/// Provide a meta-function to map integral constants to unique types.
403///
404/// @ref bslmf_movableref :
405/// Provide a vocabulary type to enable move semantics.
406///
407/// @ref bslmf_negation :
408/// Provide the logical negation (NOT) for type traits.
409///
410/// @ref bslmf_nestedtraitdeclaration :
411/// Provide a nested declaration to associate a class with a trait.
412///
413/// 'bslmf_nil':
414/// Provide a nil type.
415///
416/// @ref bslmf_nthparameter :
417/// Metafunction to return the Nth type parameter in a parameter pack
418///
419/// 'bslmf_nthparameter_cpp03': !PRIVATE!
420/// Provide C++03 implementation for bslmf_nthparameter.h
421///
422/// @ref bslmf_removeconst :
423/// Provide a meta-function for removing top-level `const`-qualifier.
424///
425/// @ref bslmf_removecv :
426/// Provide a meta-function for removing top-level cv-qualifiers.
427///
428/// @ref bslmf_removecvq :
429/// Provide a meta-function for removing `const`/`volatile` qualifiers.
430///
431/// @ref bslmf_removecvref :
432/// Provide a meta-func for removing reference-ness and cv-qualifiers.
433///
434/// @ref bslmf_removeextent :
435/// Provide a metafunction to return an array type's element type.
436///
437/// @ref bslmf_removepointer :
438/// Provide a meta-function to transform pointer type to referent type.
439///
440/// @ref bslmf_removereference :
441/// Provide a meta-function for stripping reference-ness from types.
442///
443/// @ref bslmf_removevolatile :
444/// Provide a meta-function for removing `volatile`-qualifier.
445///
446/// @ref bslmf_resulttype :
447/// Provide access to @ref result_type or `ResultType` nested type.
448///
449/// @ref bslmf_selecttrait :
450/// Provide clean compile-time dispatch based on multiple traits
451///
452/// @ref bslmf_switch :
453/// Provide a compile-time `switch` meta-function.
454///
455/// 'bslmf_tag':
456/// Provide an integral-constant-to-type conversion.
457///
458/// @ref bslmf_typeidentity :
459/// Provide a template metafunction that returns its argument.
460///
461/// @ref bslmf_typelist :
462/// Provide a typelist component.
463///
464/// @ref bslmf_usesallocator :
465/// Provide a meta-function to determine if a type uses an allocator.
466///
467/// @ref bslmf_usesallocatorargt :
468/// Provide a metafunction for `allocator_arg_t` construction
469///
470/// @ref bslmf_util :
471/// Provide low-level functions on `bslmf` types.
472///
473/// @ref bslmf_voidtype :
474/// Provide a helper for implementing SFINAE-based metafunctions.
475///
476/// @}
477/** @} */