BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bslstl_function_cpp03.h
Go to the documentation of this file.
1/// @file bslstl_function_cpp03.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslstl_function_cpp03.h -*-C++-*-
8
9// Automatically generated file. **DO NOT EDIT**
10
11#ifndef INCLUDED_BSLSTL_FUNCTION_CPP03
12#define INCLUDED_BSLSTL_FUNCTION_CPP03
13
14/// @defgroup bslstl_function_cpp03 bslstl_function_cpp03
15/// @brief Provide C++03 implementation for bslstl_function.h
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslstl
19/// @{
20/// @addtogroup bslstl_function_cpp03
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslstl_function_cpp03-purpose"> Purpose</a>
25/// * <a href="#bslstl_function_cpp03-classes"> Classes </a>
26/// * <a href="#bslstl_function_cpp03-description"> Description </a>
27///
28/// # Purpose {#bslstl_function_cpp03-purpose}
29/// Provide C++03 implementation for bslstl_function.h
30///
31/// # Classes {#bslstl_function_cpp03-classes}
32/// See bslstl_function.h for list of classes
33///
34/// @see bslstl_function
35///
36/// # Description {#bslstl_function_cpp03-description}
37/// This component is the C++03 translation of a C++11 component,
38/// generated by the 'sim_cpp11_features.pl' program. If the original header
39/// contains any specially delimited regions of C++11 code, then this generated
40/// file contains the C++03 equivalent, i.e., with variadic templates expanded
41/// and rvalue-references replaced by 'bslmf::MovableRef' objects. The header
42/// code in this file is designed to be '#include'd into the original header
43/// when compiling with a C++03 compiler. If there are no specially delimited
44/// regions of C++11 code, then this header contains no code and is not
45/// '#include'd in the original header.
46///
47/// Generated on Wed Jul 01 17:28:51 2026
48/// Command line: sim_cpp11_features.py bslstl_function.h
49/// @}
50/** @} */
51/** @} */
52
53/** @addtogroup bsl
54 * @{
55 */
56/** @addtogroup bslstl
57 * @{
58 */
59/** @addtogroup bslstl_function_cpp03
60 * @{
61 */
62
63#ifdef COMPILING_BSLSTL_FUNCTION_H
64
65// 'BSLS_ASSERT' filename fix -- See @ref bsls_assertimputil
66#ifdef BSLS_ASSERTIMPUTIL_AVOID_STRING_CONSTANTS
67
68extern const char s_bslstl_function_h[];
69#undef BSLS_ASSERTIMPUTIL_FILE
70#define BSLS_ASSERTIMPUTIL_FILE BloombergLP::s_bslstl_function_h
71
72#endif
73
74// FORWARD DECLARATIONS
75namespace bsl {
76
77/// Forward declaration.
78template <class PROTOTYPE>
79class function;
80
81} // close namespace bsl
82
83
84
85#ifndef BDE_OMIT_INTERNAL_DEPRECATED
86
87/// Forward declaration of legacy `bdef_Function` in order to implement
88/// by-reference conversion from `bsl::function<F>`. This declaration
89/// produces a by-name cyclic dependency between `bsl` and `bde` in order to
90/// allow legacy code to transition to `bsl::function` from (the deprecated)
91/// `bdef_Function`. The conversion, and therefore this forward reference,
92/// should not appear in the open-source version of this component.
93template <class PROTOTYPE>
94class bdef_Function;
95
96#endif // BDE_OMIT_INTERNAL_DEPRECATED
97
98namespace bslstl {
99
100 // =================================
101 // struct template Function_ArgTypes
102 // =================================
103
104/// This component-private struct template provides the following nested
105/// typedefs for `bsl::function` for a specified `PROTOTYPE` which must be a
106/// function type:
107/// @code
108/// argument_type -- Only if PROTOTYPE takes exactly one argument
109/// first_argument_type -- Only if PROTOTYPE takes exactly two arguments
110/// second_argument_type -- Only if PROTOTYPE takes exactly two arguments
111/// @endcode
112/// The C++ Standard requires that `function` define these typedefs for
113/// compatibility with one- and two-argument legacy (now deprecated) functor
114/// adaptors. `bsl::function` publicly inherits from an instantiation of
115/// this template in order to conditionally declare the above nested types.
116/// This primary (unspecialized) template provides no typedefs.
117///
118/// See @ref bslstl_function_cpp03
119template <class PROTOTYPE>
120struct Function_ArgTypes {
121};
122
123/// This component-private specialization of `Function_ArgTypes` is for
124/// function prototypes that take exactly one argument and provides an
125/// `argument_type` nested typedef.
126template <class RET, class ARG>
127struct Function_ArgTypes<RET(ARG)> {
128
129 // PUBLIC TYPES
130
131 /// @deprecated This typedef is deprecated in C++17, for details see
132 /// https://isocpp.org/files/papers/p0005r4.html.
134 "deprecated_cpp17_standard_library_features",
135 "do not use")
136 typedef ARG argument_type;
137};
138
139/// This component-private specialization of `Function_ArgTypes` is for
140/// functions that take exactly two arguments and provides
141/// @ref first_argument_type and @ref second_argument_type nested typedefs.
142template <class RET, class ARG1, class ARG2>
143struct Function_ArgTypes<RET(ARG1, ARG2)> {
144
145 // PUBLIC TYPES
146
147 /// @deprecated This typedef is deprecated in C++17, for details see
148 /// https://isocpp.org/files/papers/p0005r4.html.
150 "deprecated_cpp17_standard_library_features",
151 "do not use")
152 typedef ARG1 first_argument_type;
153
155 "deprecated_cpp17_standard_library_features",
156 "do not use")
157 /// @deprecated This typedef is deprecated in C++17, for details see
158 /// https://isocpp.org/files/papers/p0005r4.html.
159 typedef ARG2 second_argument_type;
160};
161
162 // ================================
163 // class template Function_Variadic
164 // ================================
165
166#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
167// {{{ BEGIN GENERATED CODE
168// Command line: sim_cpp11_features.py bslstl_function.h
169#ifndef BSLSTL_FUNCTION_VARIADIC_LIMIT
170#define BSLSTL_FUNCTION_VARIADIC_LIMIT 13
171#endif
172#ifndef BSLSTL_FUNCTION_VARIADIC_LIMIT_A
173#define BSLSTL_FUNCTION_VARIADIC_LIMIT_A BSLSTL_FUNCTION_VARIADIC_LIMIT
174#endif
175
176template <class PROTOTYPE>
177class Function_Variadic;
178
179#if BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 0
180template <class RET>
181class Function_Variadic<RET()> : public Function_ArgTypes<RET()>
182{
183
184 typedef bslstl::Function_Rep Function_Rep;
185
186 typedef RET Invoker(const Function_Rep *);
187
188 protected:
189 Function_Rep d_rep;
190
191 private:
192 Function_Variadic(const Function_Variadic&) BSLS_KEYWORD_DELETED;
193
194 Function_Variadic&
195 operator=(const Function_Variadic&) BSLS_KEYWORD_DELETED;
196
197 friend class bsl::function<RET()>;
198
199 public:
200 typedef RET result_type;
201 typedef Function_Rep::allocator_type allocator_type;
202
203
204 Function_Variadic(const allocator_type& allocator);
205
206
207
208 RET operator()() const;
209};
210#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 0
211
212#if BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 1
213template <class RET, class ARGS_01>
214class Function_Variadic<RET(ARGS_01)> : public Function_ArgTypes<RET(ARGS_01)>
215{
216
217 typedef bslstl::Function_Rep Function_Rep;
218
219 typedef RET Invoker(const Function_Rep *,
221
222 protected:
223 Function_Rep d_rep;
224
225 private:
226 Function_Variadic(const Function_Variadic&) BSLS_KEYWORD_DELETED;
227
228 Function_Variadic&
229 operator=(const Function_Variadic&) BSLS_KEYWORD_DELETED;
230
231 friend class bsl::function<RET(ARGS_01)>;
232
233 public:
234 typedef RET result_type;
235 typedef Function_Rep::allocator_type allocator_type;
236
237
238 Function_Variadic(const allocator_type& allocator);
239
240
241
242 RET operator()(ARGS_01 args_01) const;
243};
244#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 1
245
246#if BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 2
247template <class RET, class ARGS_01,
248 class ARGS_02>
249class Function_Variadic<RET(ARGS_01,
250 ARGS_02)> : public Function_ArgTypes<RET(ARGS_01,
251 ARGS_02)>
252{
253
254 typedef bslstl::Function_Rep Function_Rep;
255
256 typedef RET Invoker(const Function_Rep *,
259
260 protected:
261 Function_Rep d_rep;
262
263 private:
264 Function_Variadic(const Function_Variadic&) BSLS_KEYWORD_DELETED;
265
266 Function_Variadic&
267 operator=(const Function_Variadic&) BSLS_KEYWORD_DELETED;
268
269 friend class bsl::function<RET(ARGS_01,
270 ARGS_02)>;
271
272 public:
273 typedef RET result_type;
274 typedef Function_Rep::allocator_type allocator_type;
275
276
277 Function_Variadic(const allocator_type& allocator);
278
279
280
281 RET operator()(ARGS_01 args_01,
282 ARGS_02 args_02) const;
283};
284#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 2
285
286#if BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 3
287template <class RET, class ARGS_01,
288 class ARGS_02,
289 class ARGS_03>
290class Function_Variadic<RET(ARGS_01,
291 ARGS_02,
292 ARGS_03)> : public Function_ArgTypes<RET(ARGS_01,
293 ARGS_02,
294 ARGS_03)>
295{
296
297 typedef bslstl::Function_Rep Function_Rep;
298
299 typedef RET Invoker(const Function_Rep *,
303
304 protected:
305 Function_Rep d_rep;
306
307 private:
308 Function_Variadic(const Function_Variadic&) BSLS_KEYWORD_DELETED;
309
310 Function_Variadic&
311 operator=(const Function_Variadic&) BSLS_KEYWORD_DELETED;
312
313 friend class bsl::function<RET(ARGS_01,
314 ARGS_02,
315 ARGS_03)>;
316
317 public:
318 typedef RET result_type;
319 typedef Function_Rep::allocator_type allocator_type;
320
321
322 Function_Variadic(const allocator_type& allocator);
323
324
325
326 RET operator()(ARGS_01 args_01,
327 ARGS_02 args_02,
328 ARGS_03 args_03) const;
329};
330#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 3
331
332#if BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 4
333template <class RET, class ARGS_01,
334 class ARGS_02,
335 class ARGS_03,
336 class ARGS_04>
337class Function_Variadic<RET(ARGS_01,
338 ARGS_02,
339 ARGS_03,
340 ARGS_04)> : public Function_ArgTypes<RET(ARGS_01,
341 ARGS_02,
342 ARGS_03,
343 ARGS_04)>
344{
345
346 typedef bslstl::Function_Rep Function_Rep;
347
348 typedef RET Invoker(const Function_Rep *,
353
354 protected:
355 Function_Rep d_rep;
356
357 private:
358 Function_Variadic(const Function_Variadic&) BSLS_KEYWORD_DELETED;
359
360 Function_Variadic&
361 operator=(const Function_Variadic&) BSLS_KEYWORD_DELETED;
362
363 friend class bsl::function<RET(ARGS_01,
364 ARGS_02,
365 ARGS_03,
366 ARGS_04)>;
367
368 public:
369 typedef RET result_type;
370 typedef Function_Rep::allocator_type allocator_type;
371
372
373 Function_Variadic(const allocator_type& allocator);
374
375
376
377 RET operator()(ARGS_01 args_01,
378 ARGS_02 args_02,
379 ARGS_03 args_03,
380 ARGS_04 args_04) const;
381};
382#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 4
383
384#if BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 5
385template <class RET, class ARGS_01,
386 class ARGS_02,
387 class ARGS_03,
388 class ARGS_04,
389 class ARGS_05>
390class Function_Variadic<RET(ARGS_01,
391 ARGS_02,
392 ARGS_03,
393 ARGS_04,
394 ARGS_05)> : public Function_ArgTypes<RET(ARGS_01,
395 ARGS_02,
396 ARGS_03,
397 ARGS_04,
398 ARGS_05)>
399{
400
401 typedef bslstl::Function_Rep Function_Rep;
402
403 typedef RET Invoker(const Function_Rep *,
409
410 protected:
411 Function_Rep d_rep;
412
413 private:
414 Function_Variadic(const Function_Variadic&) BSLS_KEYWORD_DELETED;
415
416 Function_Variadic&
417 operator=(const Function_Variadic&) BSLS_KEYWORD_DELETED;
418
419 friend class bsl::function<RET(ARGS_01,
420 ARGS_02,
421 ARGS_03,
422 ARGS_04,
423 ARGS_05)>;
424
425 public:
426 typedef RET result_type;
427 typedef Function_Rep::allocator_type allocator_type;
428
429
430 Function_Variadic(const allocator_type& allocator);
431
432
433
434 RET operator()(ARGS_01 args_01,
435 ARGS_02 args_02,
436 ARGS_03 args_03,
437 ARGS_04 args_04,
438 ARGS_05 args_05) const;
439};
440#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 5
441
442#if BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 6
443template <class RET, class ARGS_01,
444 class ARGS_02,
445 class ARGS_03,
446 class ARGS_04,
447 class ARGS_05,
448 class ARGS_06>
449class Function_Variadic<RET(ARGS_01,
450 ARGS_02,
451 ARGS_03,
452 ARGS_04,
453 ARGS_05,
454 ARGS_06)> : public Function_ArgTypes<RET(ARGS_01,
455 ARGS_02,
456 ARGS_03,
457 ARGS_04,
458 ARGS_05,
459 ARGS_06)>
460{
461
462 typedef bslstl::Function_Rep Function_Rep;
463
464 typedef RET Invoker(const Function_Rep *,
471
472 protected:
473 Function_Rep d_rep;
474
475 private:
476 Function_Variadic(const Function_Variadic&) BSLS_KEYWORD_DELETED;
477
478 Function_Variadic&
479 operator=(const Function_Variadic&) BSLS_KEYWORD_DELETED;
480
481 friend class bsl::function<RET(ARGS_01,
482 ARGS_02,
483 ARGS_03,
484 ARGS_04,
485 ARGS_05,
486 ARGS_06)>;
487
488 public:
489 typedef RET result_type;
490 typedef Function_Rep::allocator_type allocator_type;
491
492
493 Function_Variadic(const allocator_type& allocator);
494
495
496
497 RET operator()(ARGS_01 args_01,
498 ARGS_02 args_02,
499 ARGS_03 args_03,
500 ARGS_04 args_04,
501 ARGS_05 args_05,
502 ARGS_06 args_06) const;
503};
504#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 6
505
506#if BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 7
507template <class RET, class ARGS_01,
508 class ARGS_02,
509 class ARGS_03,
510 class ARGS_04,
511 class ARGS_05,
512 class ARGS_06,
513 class ARGS_07>
514class Function_Variadic<RET(ARGS_01,
515 ARGS_02,
516 ARGS_03,
517 ARGS_04,
518 ARGS_05,
519 ARGS_06,
520 ARGS_07)> : public Function_ArgTypes<RET(ARGS_01,
521 ARGS_02,
522 ARGS_03,
523 ARGS_04,
524 ARGS_05,
525 ARGS_06,
526 ARGS_07)>
527{
528
529 typedef bslstl::Function_Rep Function_Rep;
530
531 typedef RET Invoker(const Function_Rep *,
539
540 protected:
541 Function_Rep d_rep;
542
543 private:
544 Function_Variadic(const Function_Variadic&) BSLS_KEYWORD_DELETED;
545
546 Function_Variadic&
547 operator=(const Function_Variadic&) BSLS_KEYWORD_DELETED;
548
549 friend class bsl::function<RET(ARGS_01,
550 ARGS_02,
551 ARGS_03,
552 ARGS_04,
553 ARGS_05,
554 ARGS_06,
555 ARGS_07)>;
556
557 public:
558 typedef RET result_type;
559 typedef Function_Rep::allocator_type allocator_type;
560
561
562 Function_Variadic(const allocator_type& allocator);
563
564
565
566 RET operator()(ARGS_01 args_01,
567 ARGS_02 args_02,
568 ARGS_03 args_03,
569 ARGS_04 args_04,
570 ARGS_05 args_05,
571 ARGS_06 args_06,
572 ARGS_07 args_07) const;
573};
574#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 7
575
576#if BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 8
577template <class RET, class ARGS_01,
578 class ARGS_02,
579 class ARGS_03,
580 class ARGS_04,
581 class ARGS_05,
582 class ARGS_06,
583 class ARGS_07,
584 class ARGS_08>
585class Function_Variadic<RET(ARGS_01,
586 ARGS_02,
587 ARGS_03,
588 ARGS_04,
589 ARGS_05,
590 ARGS_06,
591 ARGS_07,
592 ARGS_08)> : public Function_ArgTypes<RET(ARGS_01,
593 ARGS_02,
594 ARGS_03,
595 ARGS_04,
596 ARGS_05,
597 ARGS_06,
598 ARGS_07,
599 ARGS_08)>
600{
601
602 typedef bslstl::Function_Rep Function_Rep;
603
604 typedef RET Invoker(const Function_Rep *,
613
614 protected:
615 Function_Rep d_rep;
616
617 private:
618 Function_Variadic(const Function_Variadic&) BSLS_KEYWORD_DELETED;
619
620 Function_Variadic&
621 operator=(const Function_Variadic&) BSLS_KEYWORD_DELETED;
622
623 friend class bsl::function<RET(ARGS_01,
624 ARGS_02,
625 ARGS_03,
626 ARGS_04,
627 ARGS_05,
628 ARGS_06,
629 ARGS_07,
630 ARGS_08)>;
631
632 public:
633 typedef RET result_type;
634 typedef Function_Rep::allocator_type allocator_type;
635
636
637 Function_Variadic(const allocator_type& allocator);
638
639
640
641 RET operator()(ARGS_01 args_01,
642 ARGS_02 args_02,
643 ARGS_03 args_03,
644 ARGS_04 args_04,
645 ARGS_05 args_05,
646 ARGS_06 args_06,
647 ARGS_07 args_07,
648 ARGS_08 args_08) const;
649};
650#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 8
651
652#if BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 9
653template <class RET, class ARGS_01,
654 class ARGS_02,
655 class ARGS_03,
656 class ARGS_04,
657 class ARGS_05,
658 class ARGS_06,
659 class ARGS_07,
660 class ARGS_08,
661 class ARGS_09>
662class Function_Variadic<RET(ARGS_01,
663 ARGS_02,
664 ARGS_03,
665 ARGS_04,
666 ARGS_05,
667 ARGS_06,
668 ARGS_07,
669 ARGS_08,
670 ARGS_09)> : public Function_ArgTypes<RET(ARGS_01,
671 ARGS_02,
672 ARGS_03,
673 ARGS_04,
674 ARGS_05,
675 ARGS_06,
676 ARGS_07,
677 ARGS_08,
678 ARGS_09)>
679{
680
681 typedef bslstl::Function_Rep Function_Rep;
682
683 typedef RET Invoker(const Function_Rep *,
693
694 protected:
695 Function_Rep d_rep;
696
697 private:
698 Function_Variadic(const Function_Variadic&) BSLS_KEYWORD_DELETED;
699
700 Function_Variadic&
701 operator=(const Function_Variadic&) BSLS_KEYWORD_DELETED;
702
703 friend class bsl::function<RET(ARGS_01,
704 ARGS_02,
705 ARGS_03,
706 ARGS_04,
707 ARGS_05,
708 ARGS_06,
709 ARGS_07,
710 ARGS_08,
711 ARGS_09)>;
712
713 public:
714 typedef RET result_type;
715 typedef Function_Rep::allocator_type allocator_type;
716
717
718 Function_Variadic(const allocator_type& allocator);
719
720
721
722 RET operator()(ARGS_01 args_01,
723 ARGS_02 args_02,
724 ARGS_03 args_03,
725 ARGS_04 args_04,
726 ARGS_05 args_05,
727 ARGS_06 args_06,
728 ARGS_07 args_07,
729 ARGS_08 args_08,
730 ARGS_09 args_09) const;
731};
732#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 9
733
734#if BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 10
735template <class RET, class ARGS_01,
736 class ARGS_02,
737 class ARGS_03,
738 class ARGS_04,
739 class ARGS_05,
740 class ARGS_06,
741 class ARGS_07,
742 class ARGS_08,
743 class ARGS_09,
744 class ARGS_10>
745class Function_Variadic<RET(ARGS_01,
746 ARGS_02,
747 ARGS_03,
748 ARGS_04,
749 ARGS_05,
750 ARGS_06,
751 ARGS_07,
752 ARGS_08,
753 ARGS_09,
754 ARGS_10)> : public Function_ArgTypes<RET(ARGS_01,
755 ARGS_02,
756 ARGS_03,
757 ARGS_04,
758 ARGS_05,
759 ARGS_06,
760 ARGS_07,
761 ARGS_08,
762 ARGS_09,
763 ARGS_10)>
764{
765
766 typedef bslstl::Function_Rep Function_Rep;
767
768 typedef RET Invoker(const Function_Rep *,
779
780 protected:
781 Function_Rep d_rep;
782
783 private:
784 Function_Variadic(const Function_Variadic&) BSLS_KEYWORD_DELETED;
785
786 Function_Variadic&
787 operator=(const Function_Variadic&) BSLS_KEYWORD_DELETED;
788
789 friend class bsl::function<RET(ARGS_01,
790 ARGS_02,
791 ARGS_03,
792 ARGS_04,
793 ARGS_05,
794 ARGS_06,
795 ARGS_07,
796 ARGS_08,
797 ARGS_09,
798 ARGS_10)>;
799
800 public:
801 typedef RET result_type;
802 typedef Function_Rep::allocator_type allocator_type;
803
804
805 Function_Variadic(const allocator_type& allocator);
806
807
808
809 RET operator()(ARGS_01 args_01,
810 ARGS_02 args_02,
811 ARGS_03 args_03,
812 ARGS_04 args_04,
813 ARGS_05 args_05,
814 ARGS_06 args_06,
815 ARGS_07 args_07,
816 ARGS_08 args_08,
817 ARGS_09 args_09,
818 ARGS_10 args_10) const;
819};
820#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 10
821
822#if BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 11
823template <class RET, class ARGS_01,
824 class ARGS_02,
825 class ARGS_03,
826 class ARGS_04,
827 class ARGS_05,
828 class ARGS_06,
829 class ARGS_07,
830 class ARGS_08,
831 class ARGS_09,
832 class ARGS_10,
833 class ARGS_11>
834class Function_Variadic<RET(ARGS_01,
835 ARGS_02,
836 ARGS_03,
837 ARGS_04,
838 ARGS_05,
839 ARGS_06,
840 ARGS_07,
841 ARGS_08,
842 ARGS_09,
843 ARGS_10,
844 ARGS_11)> : public Function_ArgTypes<RET(ARGS_01,
845 ARGS_02,
846 ARGS_03,
847 ARGS_04,
848 ARGS_05,
849 ARGS_06,
850 ARGS_07,
851 ARGS_08,
852 ARGS_09,
853 ARGS_10,
854 ARGS_11)>
855{
856
857 typedef bslstl::Function_Rep Function_Rep;
858
859 typedef RET Invoker(const Function_Rep *,
871
872 protected:
873 Function_Rep d_rep;
874
875 private:
876 Function_Variadic(const Function_Variadic&) BSLS_KEYWORD_DELETED;
877
878 Function_Variadic&
879 operator=(const Function_Variadic&) BSLS_KEYWORD_DELETED;
880
881 friend class bsl::function<RET(ARGS_01,
882 ARGS_02,
883 ARGS_03,
884 ARGS_04,
885 ARGS_05,
886 ARGS_06,
887 ARGS_07,
888 ARGS_08,
889 ARGS_09,
890 ARGS_10,
891 ARGS_11)>;
892
893 public:
894 typedef RET result_type;
895 typedef Function_Rep::allocator_type allocator_type;
896
897
898 Function_Variadic(const allocator_type& allocator);
899
900
901
902 RET operator()(ARGS_01 args_01,
903 ARGS_02 args_02,
904 ARGS_03 args_03,
905 ARGS_04 args_04,
906 ARGS_05 args_05,
907 ARGS_06 args_06,
908 ARGS_07 args_07,
909 ARGS_08 args_08,
910 ARGS_09 args_09,
911 ARGS_10 args_10,
912 ARGS_11 args_11) const;
913};
914#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 11
915
916#if BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 12
917template <class RET, class ARGS_01,
918 class ARGS_02,
919 class ARGS_03,
920 class ARGS_04,
921 class ARGS_05,
922 class ARGS_06,
923 class ARGS_07,
924 class ARGS_08,
925 class ARGS_09,
926 class ARGS_10,
927 class ARGS_11,
928 class ARGS_12>
929class Function_Variadic<RET(ARGS_01,
930 ARGS_02,
931 ARGS_03,
932 ARGS_04,
933 ARGS_05,
934 ARGS_06,
935 ARGS_07,
936 ARGS_08,
937 ARGS_09,
938 ARGS_10,
939 ARGS_11,
940 ARGS_12)> : public Function_ArgTypes<RET(ARGS_01,
941 ARGS_02,
942 ARGS_03,
943 ARGS_04,
944 ARGS_05,
945 ARGS_06,
946 ARGS_07,
947 ARGS_08,
948 ARGS_09,
949 ARGS_10,
950 ARGS_11,
951 ARGS_12)>
952{
953
954 typedef bslstl::Function_Rep Function_Rep;
955
956 typedef RET Invoker(const Function_Rep *,
969
970 protected:
971 Function_Rep d_rep;
972
973 private:
974 Function_Variadic(const Function_Variadic&) BSLS_KEYWORD_DELETED;
975
976 Function_Variadic&
977 operator=(const Function_Variadic&) BSLS_KEYWORD_DELETED;
978
979 friend class bsl::function<RET(ARGS_01,
980 ARGS_02,
981 ARGS_03,
982 ARGS_04,
983 ARGS_05,
984 ARGS_06,
985 ARGS_07,
986 ARGS_08,
987 ARGS_09,
988 ARGS_10,
989 ARGS_11,
990 ARGS_12)>;
991
992 public:
993 typedef RET result_type;
994 typedef Function_Rep::allocator_type allocator_type;
995
996
997 Function_Variadic(const allocator_type& allocator);
998
999
1000
1001 RET operator()(ARGS_01 args_01,
1002 ARGS_02 args_02,
1003 ARGS_03 args_03,
1004 ARGS_04 args_04,
1005 ARGS_05 args_05,
1006 ARGS_06 args_06,
1007 ARGS_07 args_07,
1008 ARGS_08 args_08,
1009 ARGS_09 args_09,
1010 ARGS_10 args_10,
1011 ARGS_11 args_11,
1012 ARGS_12 args_12) const;
1013};
1014#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 12
1015
1016#if BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 13
1017template <class RET, class ARGS_01,
1018 class ARGS_02,
1019 class ARGS_03,
1020 class ARGS_04,
1021 class ARGS_05,
1022 class ARGS_06,
1023 class ARGS_07,
1024 class ARGS_08,
1025 class ARGS_09,
1026 class ARGS_10,
1027 class ARGS_11,
1028 class ARGS_12,
1029 class ARGS_13>
1030class Function_Variadic<RET(ARGS_01,
1031 ARGS_02,
1032 ARGS_03,
1033 ARGS_04,
1034 ARGS_05,
1035 ARGS_06,
1036 ARGS_07,
1037 ARGS_08,
1038 ARGS_09,
1039 ARGS_10,
1040 ARGS_11,
1041 ARGS_12,
1042 ARGS_13)> : public Function_ArgTypes<RET(ARGS_01,
1043 ARGS_02,
1044 ARGS_03,
1045 ARGS_04,
1046 ARGS_05,
1047 ARGS_06,
1048 ARGS_07,
1049 ARGS_08,
1050 ARGS_09,
1051 ARGS_10,
1052 ARGS_11,
1053 ARGS_12,
1054 ARGS_13)>
1055{
1056
1057 typedef bslstl::Function_Rep Function_Rep;
1058
1059 typedef RET Invoker(const Function_Rep *,
1073
1074 protected:
1075 Function_Rep d_rep;
1076
1077 private:
1078 Function_Variadic(const Function_Variadic&) BSLS_KEYWORD_DELETED;
1079
1080 Function_Variadic&
1081 operator=(const Function_Variadic&) BSLS_KEYWORD_DELETED;
1082
1083 friend class bsl::function<RET(ARGS_01,
1084 ARGS_02,
1085 ARGS_03,
1086 ARGS_04,
1087 ARGS_05,
1088 ARGS_06,
1089 ARGS_07,
1090 ARGS_08,
1091 ARGS_09,
1092 ARGS_10,
1093 ARGS_11,
1094 ARGS_12,
1095 ARGS_13)>;
1096
1097 public:
1098 typedef RET result_type;
1099 typedef Function_Rep::allocator_type allocator_type;
1100
1101
1102 Function_Variadic(const allocator_type& allocator);
1103
1104
1105
1106 RET operator()(ARGS_01 args_01,
1107 ARGS_02 args_02,
1108 ARGS_03 args_03,
1109 ARGS_04 args_04,
1110 ARGS_05 args_05,
1111 ARGS_06 args_06,
1112 ARGS_07 args_07,
1113 ARGS_08 args_08,
1114 ARGS_09 args_09,
1115 ARGS_10 args_10,
1116 ARGS_11 args_11,
1117 ARGS_12 args_12,
1118 ARGS_13 args_13) const;
1119};
1120#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_A >= 13
1121
1122#else
1123// The generated code below is a workaround for the absence of perfect
1124// forwarding in some compilers.
1125
1126template <class PROTOTYPE>
1127class Function_Variadic;
1128
1129template <class RET, class... ARGS>
1130class Function_Variadic<RET(ARGS...)> : public Function_ArgTypes<RET(ARGS...)>
1131{
1132
1133 typedef bslstl::Function_Rep Function_Rep;
1134
1135 typedef RET Invoker(const Function_Rep *,
1137
1138 protected:
1139 Function_Rep d_rep;
1140
1141 private:
1142 Function_Variadic(const Function_Variadic&) BSLS_KEYWORD_DELETED;
1143
1144 Function_Variadic&
1145 operator=(const Function_Variadic&) BSLS_KEYWORD_DELETED;
1146
1147 friend class bsl::function<RET(ARGS...)>;
1148
1149 public:
1150 typedef RET result_type;
1151 typedef Function_Rep::allocator_type allocator_type;
1152
1153
1154 Function_Variadic(const allocator_type& allocator);
1155
1156
1157
1158 RET operator()(ARGS... args) const;
1159};
1160
1161// }}} END GENERATED CODE
1162#endif
1163
1164 // =================================================
1165 // struct template Function_IsInvocableWithPrototype
1166 // =================================================
1167
1168/// Forward declaration of the component-private
1169/// `Function_IsInvocableWithPrototype` `struct` template. The primary
1170/// (unspecialized) template is not defined. This `struct` template
1171/// implements a boolean metafunction that publicly inherits from
1172/// `bsl::true_type` if an object of the specified `FUNC` type is invocable
1173/// under the specified `PROTOTYPE`, and inherits from `bsl::false_type`
1174/// otherwise. An object of `FUNC` type is invocable under the `PROTOTYPE`
1175/// if it is Lvalue-Callable with the arguments of the `PROTOTYPE`, and
1176/// returns an object of type convertible to the return type of the
1177/// `PROTOTYPE`. If the return type of the `PROTOTYPE` is `void`, then any
1178/// type is considered convertible to the return type of the `PROTOTYPE`.
1179/// In C++03, `FUNC` is considered Lvalue-Callable with the argument and
1180/// return types of the `PROTOTYPE` if it is not an integral type. This
1181/// `struct` template requires `PROTOTYPE` to be an unqualified function
1182/// type.
1183template <class PROTOTYPE, class FUNC>
1184struct Function_IsInvocableWithPrototype;
1185
1186} // close package namespace
1187
1188
1189namespace bsl {
1190
1191 // =======================
1192 // class template function
1193 // =======================
1194
1195/// This class template implements the C++ Standard Library `std::function`
1196/// template, enhanced for allocator support as per Standards Proposal
1197/// P0987. An instantiation of this template generalizes the notion of a
1198/// pointer to a function having the specified `PROTOTYPE` expressed as a
1199/// function type (e.g., `int(const char *, float)`). An object of this
1200/// class wraps a copy of the callable object specified at construction (if
1201/// any), such as a function pointer, member-function pointer, member-data
1202/// pointer, or functor object. The wrapped object (called the *target* or
1203/// *target* *object*) is owned by the `bsl::function` object (unlike the
1204/// function pointer that it mimics). Invoking the `bsl::function` object
1205/// will invoke the target (or throw an exception, if there is no target).
1206///
1207/// \note Note that `function` will compile only if `PROTOTYPE` is a function
1208/// type.
1209///
1210/// To optimize away many heap allocations, objects of this type have a
1211/// buffer into which small callable objects can be stored. In order to
1212/// qualify for this small-object optimization, a callable type must not
1213/// only fit in the buffer but must also be nothrow move constructible. The
1214/// latter constraint allows this type to be nothrow move constructible and
1215/// nothrow swappable, as required by the C++ Standard. The small object
1216/// buffer is guaranteed to be large enough to hold a pointer to function,
1217/// pointer to member function, pointer to member data, a
1218/// `bsl::reference_wrapper`, or an empty struct. Although the standard
1219/// does not specify a minimum size beyond the aforementioned guarantee,
1220/// many small structs will fit in the small object buffer, as defined in
1221/// the @ref bslstl_function_smallobjectoptimization component.
1222///
1223/// See @ref bslstl_function_cpp03
1224template <class PROTOTYPE>
1225class function : public BloombergLP::bslstl::Function_Variadic<PROTOTYPE> {
1226
1227 private:
1228 // PRIVATE TYPES
1229 typedef BloombergLP::bslstl::Function_Variadic<PROTOTYPE> Base;
1230 typedef BloombergLP::bslstl::Function_Rep Function_Rep;
1231 typedef BloombergLP::bslmf::MovableRefUtil MovableRefUtil;
1232
1233 /// Abbreviation for metafunction that determines whether a reference
1234 /// from `FROM` can be cast to a reference to `TO` without loss of
1235 /// information.
1236 template <class FROM, class TO>
1237 struct IsReferenceCompatible
1238 : BloombergLP::bslstl::Function_IsReferenceCompatible<FROM, TO>::type {
1239 };
1240
1241 /// Abbreviation for metafunction used to provide a C++03-compatible
1242 /// implementation of `std::decay` that treats `bslmf::MovableReference`
1243 /// as an rvalue reference.
1244 template <class TYPE>
1245 struct Decay : MovableRefUtil::Decay<TYPE> {
1246 };
1247
1248 /// Abbreviation for a metafunction used to determine whether an object
1249 /// of the specified `FUNC` is callable with argument types of the
1250 /// specified `PROTOTYPE` and returns a type convertible to the return
1251 /// type of the `PROTOTYPE`.
1252 template <class FUNC>
1253 struct IsInvocableWithPrototype
1254 : BloombergLP::bslstl::Function_IsInvocableWithPrototype<PROTOTYPE, FUNC> {
1255 };
1256
1257#ifndef BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
1258 /// Unique type that evaluates to true or false in a boolean control
1259 /// construct such as an `if` or `while` statement. In C++03,
1260 /// `function` is implicitly convertible to this type but is not
1261 /// implicitly convertible to `bool`. In C++11 and later, `function` is
1262 /// explicitly convertible to `bool`, so this type is not needed.
1263 typedef BloombergLP::bsls::UnspecifiedBool<function> UnspecifiedBoolUtil;
1264 typedef typename UnspecifiedBoolUtil::BoolType UnspecifiedBool;
1265
1266 private:
1267 // NOT IMPLEMENTED
1268
1269 /// Since `function` does not support `operator==` and `operator!=`,
1270 /// they must be deliberately suppressed; otherwise `function` objects
1271 /// would be implicitly comparable by implicit conversion to
1272 /// `UnspecifiedBool`.
1273 bool operator==(const function&) const; // Declared but not defined
1274 bool operator!=(const function&) const; // Declared but not defined
1275#endif // !defined(BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT)
1276
1277 // PRIVATE MANIPULATORS
1278
1279 /// Set the target of this `function` by constructing from the specified
1280 /// `func` callable object. If the type of `func` is a movable
1281 /// reference, then the target is constructed by extended move
1282 /// construction; otherwise by extended copy construction.
1283 /// Instantiation will fail unless `FUNC` is a callable type that is
1284 /// invocable with arguments in `PROTOTYPE` and yields a return type
1285 /// that is convertible to the return type in `PROTOTYPE`.
1286 template <class FUNC>
1287 void installFunc(BSLS_COMPILERFEATURES_FORWARD_REF(FUNC) func);
1288
1289 public:
1290 // TRAITS
1292 BloombergLP::bslma::UsesBslmaAllocator);
1294 BloombergLP::bslmf::UsesAllocatorArgT);
1297
1298 // TYPES
1299 typedef Function_Rep::allocator_type allocator_type;
1300
1301 // CREATORS
1302 function() BSLS_KEYWORD_NOEXCEPT;
1303 function(nullptr_t) BSLS_KEYWORD_NOEXCEPT; // IMPLICIT
1304 function(allocator_arg_t ,
1305 const allocator_type& allocator) BSLS_KEYWORD_NOEXCEPT;
1306
1307 /// Create an empty `function` object. Optionally specify an
1308 /// `allocator` (e.g., the address of a `bslma::Allocator` object) to
1309 /// supply memory; otherwise, the default allocator is used.
1310 function(allocator_arg_t ,
1311 const allocator_type& allocator,
1312 nullptr_t ) BSLS_KEYWORD_NOEXCEPT;
1313
1314 /// Create an object wrapping the specified `func` callable object. Use
1315 /// the default allocator to supply memory. If `func` is a null pointer
1316 /// or null pointer-to-member, then the resulting object will be empty.
1317 /// This constructor will not participate in overload resolution if
1318 /// `func` is of the same type as (or reference compatible with) this
1319 /// object (to avoid ambiguity with the copy and move constructors) or
1320 /// is an integral type (to avoid matching null pointer literals). In
1321 /// C++03, this function will not participate in overload resolution if
1322 /// `FUNC` is a `MovableRef` (see overload, below), and instantiation
1323 /// will fail unless `FUNC` is invocable using the arguments and return
1324 /// type specified in `PROTOTYPE`. In C++11 and later, this function
1325 /// will not participate in overload resolution if `FUNC` is not
1326 /// invocable using the arguments and return type specified in `PROTOTYPE`.
1327 ///
1328 /// \note Note that this constructor implicitly converts from
1329 /// any type that is so invocable.
1330 template <class FUNC>
1331 function(BSLS_COMPILERFEATURES_FORWARD_REF(FUNC) func, // IMPLICIT
1332 typename enable_if<
1333 ! IsReferenceCompatible<typename Decay<FUNC>::type,
1334 function>::value
1335 && IsInvocableWithPrototype<
1336 typename Decay<FUNC>::type>::value
1337#ifndef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
1338 && ! MovableRefUtil::IsMovableReference<FUNC>::value
1339#endif
1340#ifdef BSLS_PLATFORM_CMP_IBM
1341 && ! is_function<FUNC>::value
1342#endif
1343 , int>::type = 0)
1344 : Base(allocator_type())
1345 {
1346 ///Implementation Note
1347 ///- - - - - - - - - -
1348 // The body of this constructor must be inlined inplace because the use
1349 // of `enable_if` will otherwise break the MSVC 2010 compiler.
1350 //
1351 // The `! bsl::is_function<FUNC>::value` constraint is required in
1352 // C++03 mode when using the IBM XL C++ compiler. In C++03,
1353 // `BSLS_COMPILERFEATURES_FORWARD_REF(FUNC) func` expands to
1354 // `const FUNC& func`. A conforming compiler deduces a
1355 // reference-to-function type for `func` when it binds to a function
1356 // argument. The IBM XL C++ compiler erroneously does not collapse the
1357 // `const` qualifier when `FUNC` is deduced to be a function type, and
1358 // instead attempts to deduce the type of `func` to be a reference to a
1359 // `const`-qualified function. This causes substitution to fail
1360 // because function-typed expressions are never `const`. This
1361 // component solves the problem by accepting a `func` having a function
1362 // type as a pointer to a (non-`const`) function. An overload for the
1363 // corresponding constructor is defined below.
1364
1365 installFunc(BSLS_COMPILERFEATURES_FORWARD(FUNC, func));
1366 }
1367
1368#ifdef BSLS_PLATFORM_CMP_IBM
1369 template <class FUNC>
1370 function(FUNC *func, // IMPLICIT
1371 typename enable_if<is_function<FUNC>::value, int>::type = 0)
1372
1373 : Base(allocator_type())
1374 {
1375 ///Implementation Note
1376 ///- - - - - - - - - -
1377 // This constructor overload only exists to work around an IBM XL C++
1378 // compiler defect. See the implementation notes for the above
1379 // constructor overload for more information.
1380 //
1381 // This constructor also forwards the `func` as a pointer-to-function
1382 // type to downstream operations in order to work around the
1383 // aforementioned reference-to-function type deduction defects.
1384 //
1385 // Further, note that instantiation of this constructor will fail
1386 // unless `FUNC` is invocable using the arguments and return type
1387 // specified in `PROTOTYPE`. This component assumes that the IBM XL
1388 // C++ compiler does not support C++11 or later.
1389
1390 installFunc(func);
1391 }
1392#endif
1393
1394#ifndef BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES
1395 /// Create an object wrapping the specified `func` callable object.
1396 /// This constructor (ctor 2) is identical to the previous constructor
1397 /// (ctor 1) except that, in C++03 ctor 2 provides for explicit
1398 /// construction from a `MovableRef` referencing a callable type, rather
1399 /// than an implicit conversion for `FUNC` not being a `MovableRef`. In
1400 /// C++11, overload resolution matching an argument of type `T&&` to a
1401 /// parameter of type `T` (exact match) is always preferred over
1402 /// matching `T&&` to `bsl::function` (conversion). In C++03, however
1403 /// `MovableRef` is not a real reference type, so it sometimes creates
1404 /// overload ambiguities whereby matching `MovableRef<T>` to `T`
1405 /// (conversion) is no better than matching `MovableRef<T>` to
1406 /// `bsl::function` (also conversion). This ambiguity is resolved by
1407 /// making this constructor from `MovableRef<T>` explicit, while leaving
1408 /// other constructor from `FUNC` implicit. This means that
1409 /// `move` will fail in a narrow set of cases in C++03, as shown below:
1410 /// @code
1411 /// typedef bsl::function<void(int)> Obj;
1412 /// MyCallableType x;
1413 ///
1414 /// Obj f1 = x; // OK
1415 /// Obj f2 = bslmf::MovableRefUtil::move(x); // No conversion in C++03
1416 /// Obj f3(bslmf::MovableRefUtil::move(x)); // OK, normal ctor call
1417 ///
1418 /// void y(const Obj& f);
1419 /// y(x); // OK
1420 /// y(bslmf::MovableRefUtil::move(x)); // Not found in C++03
1421 /// y(Obj(bslmf::MovableRefUtil::move(x))); // OK, explicit cast
1422 /// @endcode
1423 /// As you can see from the examples above, there are simple workarounds
1424 /// for the problem cases, although generic code might need to be extra
1425 /// careful.
1426 template <class FUNC>
1427 explicit function(const BloombergLP::bslmf::MovableRef<FUNC>& func,
1428 typename enable_if<
1429 ! IsReferenceCompatible<typename Decay<FUNC>::type,
1430 function>::value
1431 && IsInvocableWithPrototype<
1432 typename Decay<FUNC>::type>::value
1433 , int>::type = 0)
1434 : Base(allocator_type())
1435 {
1436 ///Implementation Note
1437 ///- - - - - - - - - -
1438 // The body of this constructor must inlined inplace because the use of
1439 // `enable_if` will otherwise break the MSVC 2010 compiler.
1440
1441 installFunc(BloombergLP::bslmf::MovableRefUtil::move(func));
1442 }
1443#endif
1444
1445 /// Create an object wrapping the specified `func` callable object. Use
1446 /// the specified `allocator` (i.e., the address of a `bslma::Allocator`
1447 /// object) to supply memory. If `func` is a null pointer or null
1448 /// pointer-to-member, then the resulting object will be empty. This
1449 /// constructor will not participate in overload resolution if `func` is
1450 /// of the same type as (or reference compatible with) this object (to
1451 /// avoid ambiguity with the extended copy and move constructors) or is
1452 /// an integral type (to avoid matching null pointer literals). In
1453 /// C++03, this function will not participate in overload resolution if
1454 /// `FUNC` is a `MovableRef` (see overload, below), and instantiation
1455 /// will fail unless `FUNC` is invocable using the arguments and return
1456 /// type specified in `PROTOTYPE`. In C++11 and later, this function
1457 /// will not participate in overload resolution if `FUNC` is not
1458 /// invocable using the arguments and return type specified in `PROTOTYPE`.
1459 ///
1460 /// \note Note that this constructor implicitly converts from
1461 /// any type that is so invocable.
1462 template <class FUNC>
1463 function(allocator_arg_t,
1464 const allocator_type& allocator,
1466 typename enable_if<
1467 ! IsReferenceCompatible<typename Decay<FUNC>::type,
1468 function>::value
1469 && IsInvocableWithPrototype<
1470 typename Decay<FUNC>::type>::value
1471#ifdef BSLS_PLATFORM_CMP_IBM
1472 && ! is_function<FUNC>::value
1473#endif
1474 , int>::type = 0)
1475 : Base(allocator)
1476 {
1477 ///Implementation Note
1478 ///- - - - - - - - - -
1479 // The body of this constructor must inlined inplace because the use of
1480 // `enable_if` will otherwise break the MSVC 2010 compiler.
1481 //
1482 // The `! bsl::is_function<FUNC>::value` constraint is required in
1483 // C++03 mode when using the IBM XL C++ compiler. In C++03,
1484 // `BSLS_COMPILERFEATURES_FORWARD_REF(FUNC) func` expands to
1485 // `const FUNC& func`. A conforming compiler deduces a
1486 // reference-to-function type for `func` when it binds to a function
1487 // argument. The IBM XL C++ compiler erroneously does not collapse the
1488 // `const` qualifier when `FUNC` is deduced to be a function type, and
1489 // instead attempts to deduce the type of `func` to be a reference to a
1490 // `const`-qualified function. This causes substitution to fail
1491 // because function-typed expressions are never `const`. This
1492 // component solves the problem by accepting a `func` having a function
1493 // type as a pointer to a (non-`const`) function. An overload for the
1494 // corresponding constructor is defined below.
1495
1496 installFunc(BSLS_COMPILERFEATURES_FORWARD(FUNC, func));
1497 }
1498
1499#ifdef BSLS_PLATFORM_CMP_IBM
1500 template <class FUNC>
1501 function(allocator_arg_t,
1502 const allocator_type& allocator,
1503 FUNC *func,
1504 typename enable_if<is_function<FUNC>::value, int>::type = 0)
1505 : Base(allocator)
1506 {
1507 ///Implementation Note
1508 ///- - - - - - - - - -
1509 // This constructor overload only exists to work around an IBM XL C++
1510 // compiler defect. See the implementation notes for the above
1511 // constructor overload for more information.
1512 //
1513 // This constructor also forwards the `func` as a pointer-to-function
1514 // type to downstream operations in order to work around the
1515 // aforementioned reference-to-function type deduction defects.
1516 //
1517 // Further, note that instantiation of this constructor will fail
1518 // unless `FUNC` is invocable using the arguments and return type
1519 // specified in `PROTOTYPE`. This component assumes that the IBM XL
1520 // C++ compiler does not support C++11 or later.
1521
1522 installFunc(func);
1523 }
1524#endif
1525
1526 /// Create a `function` having the same value as (i.e., wrapping a copy
1527 /// of the target held by) the specified `original` object. Optionally
1528 /// specify an `allocator` (e.g., the address of a `bslma::Allocator`
1529 /// object) to supply memory; otherwise, the default allocator is used.
1530 function(const function& original);
1531 function(allocator_arg_t ,
1532 const allocator_type& allocator,
1533 const function& original);
1534
1535 /// Create a `function` having the same target as the specified
1536 /// `original` object. Use `original.get_allocator()` as the allocator
1537 /// to supply memory. The `original` object is set to empty after the
1538 /// new object is created. If the target qualifies for the small-object
1539 /// optimization (see class-level documentation), then it is
1540 /// move-constructed into the new object; otherwise ownership of the
1541 /// target is transferred without using the target's move constructor.
1542 function(BloombergLP::bslmf::MovableRef<function> original)
1543 BSLS_KEYWORD_NOEXCEPT; // IMPLICIT
1544
1545 /// Create a `function` having the same value as (i.e., wrapping a copy
1546 /// of the target held by) the specified `original` object. Use the
1547 /// specified `allocator` (e.g., the address of a `bslma::Allocator`
1548 /// object) to supply memory. If `allocator == original.allocator()`,
1549 /// this object is created as if by move construction; otherwise it is
1550 /// created as if by extended copy construction using `allocator`.
1551 function(allocator_arg_t ,
1552 const allocator_type& allocator,
1553 BloombergLP::bslmf::MovableRef<function> original);
1554
1555 // MANIPULATORS
1556
1557 /// Set the target of this object to a copy of the target (if any)
1558 /// held by the specified `rhs` object, destroy the target (if any)
1559 /// previously held by `*this`, and return `*this`. The result is
1560 /// equivalent to having constructed `*this` from `rhs` using the
1561 /// extended copy constructor with allocator `this->get_allocator()`.
1562 /// If an exception is thrown, `*this` is not modified (i.e., copy
1563 /// assignment provides the strong exception guarantee).
1564 function& operator=(const function& rhs);
1565
1566 /// Set the target of this object to the target (if any) held by the
1567 /// specified `rhs` object, destroy the target (if any) previously held
1568 /// by `*this`, and return `*this`. The result is equivalent to having
1569 /// constructed `*this` from `rhs` using the extended move constructor
1570 /// with allocator `this->get_allocator()`. If an exception is thrown,
1571 /// `rhs` will have a valid but unspecified value and `*this` will not be modified.
1572 ///
1573 /// \note Note that an exception will never be thrown if
1574 /// `get_allocator() == rhs.get_allocator()`.
1575 function& operator=(BloombergLP::bslmf::MovableRef<function> rhs);
1576
1577 /// Set the target of this object to the specified `rhs` callable
1578 /// object, destroy the previous target (if any), and return `*this`.
1579 /// The result is equivalent to having constructed `*this` from
1580 /// `std::forward<FUNC>(rhs)` and `this->get_allocator()`.
1581 ///
1582 /// \note Note that this assignment operator will not participate in overload resolution
1583 /// if `func` is of the same type as this object (to avoid ambiguity
1584 /// with the copy and move assignment operators.) In C++03,
1585 /// instantiation will fail unless `FUNC` is invocable with the
1586 /// arguments and return type specified in `PROTOTYPE`. In C++11 and
1587 /// later, this assignment operator will not participate in overload
1588 /// resolution unless `FUNC` is invocable with the arguments and return
1589 /// type specified in `PROTOTYPE`.
1590 template <class FUNC>
1591 typename enable_if<
1592 ! IsReferenceCompatible<typename Decay<FUNC>::type, function>::value
1593 && IsInvocableWithPrototype<typename Decay<FUNC>::type>::value
1594 , function&>::type
1595 operator=(BSLS_COMPILERFEATURES_FORWARD_REF(FUNC) rhs)
1596 {
1597 ///Implementation Note
1598 ///- - - - - - - - - -
1599 // The body of this operator must inlined inplace because the use of
1600 // `enable_if` will otherwise break the MSVC 2010 compiler.
1601
1602 function(allocator_arg, this->get_allocator(),
1603 BSLS_COMPILERFEATURES_FORWARD(FUNC, rhs)).swap(*this);
1604 return *this;
1605 }
1606
1607#ifdef BSLS_PLATFORM_CMP_IBM
1608 /// Set the target of this object to the specified `rhs` function
1609 /// pointer. This overload exists only for the IBM compiler, which has
1610 /// trouble decaying functions to function pointers in
1611 /// pass-by-const-reference template arguments.
1612 template <class FUNC>
1613 typename enable_if<is_function<FUNC>::value, function&>::type
1614 operator=(FUNC *rhs)
1615 {
1616 ///Implementation Note
1617 ///- - - - - - - - - -
1618 // The body of this operator must inlined inplace.
1619 //
1620 // Further, note that instantiation of this assignment operator will
1621 // fail unless `FUNC` is invocable using the arguments and return type
1622 // specified in `PROTOTYPE`. This component assumes that the IBM XL
1623 // C++ compiler does not support C++11 or later.
1624
1625 function(allocator_arg, this->get_allocator(), rhs).swap(*this);
1626 return *this;
1627 }
1628#endif
1629
1630 /// Destroy the current target (if any) of this object, then set the
1631 /// target to the specified `rhs` wrapper containing a reference to a
1632 /// callable object and return `*this`. The result is equivalent to
1633 /// having constructed `*this` from `rhs` and `this->get_allocator()`.
1634 ///
1635 /// \note Note that this assignment is a separate overload only because it is
1636 /// unconditionally `noexcept`.
1637 template <class FUNC>
1638 typename enable_if<
1639 IsInvocableWithPrototype<typename Decay<FUNC>::type>::value
1640 , function &>::type
1642 {
1643 /// Implementation Note
1644 ///- - - - - - - - - -
1645 // The body of this operator must inlined inplace because the use of
1646 // 'enable_if' will otherwise break the MSVC 2010 compiler.
1647
1648 function(allocator_arg, this->get_allocator(), rhs).swap(*this);
1649 return *this;
1650 }
1651
1652 /// Set this object to empty and return `*this`.
1653 function& operator=(nullptr_t) BSLS_KEYWORD_NOEXCEPT;
1654
1655 // Inherit 'operator()' from 'Function_Variadic' base class.
1656
1657 /// If this object is empty, throw `bsl::bad_function_call`; otherwise
1658 /// invoke the target object with the specified `args...` and return the result (after conversion to `RET`).
1659 ///
1660 /// \note Note that, even though it is
1661 /// declared `const`, this call operator can mutate the target object
1662 /// and is thus considered a manipulator rather than an accessor.
1663 using Base::operator();
1664
1665 /// Exchange the targets held by this `function` and the specified `other` `function`.
1666 ///
1667 /// \pre The behavior is undefined unless
1668 /// `get_allocator() == other.get_allocator()`.
1669 void swap(function& other) BSLS_KEYWORD_NOEXCEPT;
1670
1671 /// If `TP` is the same type as the target object, returns a pointer
1672 /// granting modifiable access to the target; otherwise return a null
1673 /// pointer.
1674 template<class TP> TP* target() BSLS_KEYWORD_NOEXCEPT;
1675
1676 // ACCESSORS
1677#ifdef BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
1678 /// (C++11 and later) Return false if this object is empty, otherwise return true.
1679 ///
1680 /// \note Note that this is an explicit conversion operator and
1681 /// is typically invoked implicitly in contexts such as in the condition
1682 /// of an `if` or `while` statement, though it can also be invoked via
1683 /// an explicit cast.
1684 explicit // Explicit conversion available only with C++11
1685 operator bool() const BSLS_KEYWORD_NOEXCEPT;
1686#else
1687 /// (C++03 only) Return a null value if this object is empty, otherwise an arbitrary non-null value.
1688 ///
1689 /// \note Note that this operator will be
1690 /// invoked implicitly in boolean contexts such as in the condition of
1691 /// an `if` or `while` statement, but does not constitute an implicit
1692 /// conversion to `bool`.
1693 operator UnspecifiedBool() const BSLS_KEYWORD_NOEXCEPT
1694 {
1695 // Inplace inlined to work around xlC bug when out-of-line.
1696 return UnspecifiedBoolUtil::makeValue(0 != this->d_rep.invoker());
1697 }
1698#endif
1699
1700 /// Return (a copy of) the allocator used to supply memory for this
1701 /// `function`.
1702 allocator_type get_allocator() const BSLS_KEYWORD_NOEXCEPT;
1703
1704 /// If `TP` is the same type as the target object, returns a pointer
1705 /// granting read-only access to the target; otherwise return a null
1706 /// pointer.
1707 template<class TP> const TP* target() const BSLS_KEYWORD_NOEXCEPT;
1708
1709 /// Return `typeid(void)` if this object is empty; otherwise
1710 /// `typeid(FUNC)` where `FUNC` is the type of the target object.
1711 const std::type_info& target_type() const BSLS_KEYWORD_NOEXCEPT;
1712
1713#ifndef BDE_OMIT_INTERNAL_DEPRECATED
1714 // LEGACY METHODS
1715
1716 /// Return `*this`, converted to a mutable `bdef_Function` reference by downcasting.
1717 ///
1718 /// \pre The behavior is undefined unless `bdef_Function<F*>`
1719 /// is derived from `bsl::function<F>` and adds no new data members.
1720 ///
1721 /// @deprecated Use @ref bsl::function` instead of `bdef_Function.
1722 operator BloombergLP::bdef_Function<PROTOTYPE *>&() BSLS_KEYWORD_NOEXCEPT;
1723
1724 /// Return `*this` converted to a const `bdef_Function` reference by downcasting.
1725 ///
1726 /// \pre The behavior is undefined unless `bdef_Function<F*>`
1727 /// is derived from `bsl::function<F>` and adds no new data members.
1728 ///
1729 /// @deprecated Use @ref bsl::function` instead of `bdef_Function.
1730 operator const BloombergLP::bdef_Function<PROTOTYPE *>&() const
1732
1733 // LEGACY ACCESSORS
1734
1735 /// Return `get_allocator().mechanism()`.
1736 /// \note Note that this function exists
1737 /// for BDE compatibility and is not part of the C++ Standard Library.
1738 ///
1739 /// @deprecated Use @ref get_allocator() instead.
1740 BloombergLP::bslma::Allocator *allocator() const BSLS_KEYWORD_NOEXCEPT;
1741
1742 /// Return `true` if this `function` is empty or if it is non-empty and
1743 /// its target qualifies for the small-object optimization (and is thus
1744 /// allocated within this object's footprint); otherwise, return false.
1745 ///
1746 /// @deprecated Runtime checking of this optimization is discouraged.
1747 bool isInplace() const BSLS_KEYWORD_NOEXCEPT;
1748#endif
1749};
1750
1751#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
1752// CLASS TEMPLATE DEDUCTION GUIDES
1753
1754/// Deduce the template parameter `PROTOTYPE` from the signature of the
1755/// function supplied to the constructor of `function`.
1756template<class RET, class... ARGS>
1757function(RET(*)(ARGS...)) -> function<RET(ARGS...)>;
1758
1759/// Deduce the template parameter `PROTOTYPE` from the signature of the
1760/// function supplied to the constructor of `function`.
1761template<class ALLOC, class RET, class... ARGS>
1762function(allocator_arg_t, ALLOC, RET(*)(ARGS...)) -> function<RET(ARGS...)>;
1763
1764
1765/// This struct provides a set of template `meta-functions` that extract
1766/// the signature of a class member function, stripping any qualifiers such
1767/// as `const`, `noexcept` or `&`.
1768///
1769/// See @ref bslstl_function_cpp03
1770struct FunctionDeductionHelper {
1771
1772 public:
1773 // PUBLIC TYPES
1774 template<class FUNCTOR>
1775 struct StripSignature {};
1776
1777 template<class RET, class FUNCTOR, class ...ARGS>
1778 struct StripSignature<RET (FUNCTOR::*) (ARGS...)>
1779 { using Sig = RET(ARGS...); };
1780
1781 template<class RET, class FUNCTOR, class ...ARGS>
1782 struct StripSignature<RET (FUNCTOR::*) (ARGS...) const>
1783 { using Sig = RET(ARGS...); };
1784
1785 template<class RET, class FUNCTOR, class ...ARGS>
1786 struct StripSignature<RET (FUNCTOR::*) (ARGS...) noexcept>
1787 { using Sig = RET(ARGS...); };
1788
1789 template<class RET, class FUNCTOR, class ...ARGS>
1790 struct StripSignature<RET (FUNCTOR::*) (ARGS...) const noexcept>
1791 { using Sig = RET(ARGS...); };
1792
1793 template<class RET, class FUNCTOR, class ...ARGS>
1794 struct StripSignature<RET (FUNCTOR::*) (ARGS...) &>
1795 { using Sig = RET(ARGS...); };
1796
1797 template<class RET, class FUNCTOR, class ...ARGS>
1798 struct StripSignature<RET (FUNCTOR::*) (ARGS...) const &>
1799 { using Sig = RET(ARGS...); };
1800
1801 template<class RET, class FUNCTOR, class ...ARGS>
1802 struct StripSignature<RET (FUNCTOR::*) (ARGS...) & noexcept>
1803 { using Sig = RET(ARGS...); };
1804
1805 template<class RET, class FUNCTOR, class ...ARGS>
1806 struct StripSignature<RET (FUNCTOR::*) (ARGS...) const & noexcept>
1807 { using Sig = RET(ARGS...); };
1808};
1809
1810/// Deduce the template parameter `PROTOTYPE` from the signature of the
1811/// `operator()` of the functor supplied to the constructor of `function`.
1812template <
1813 class FP,
1814 class PROTOTYPE = typename
1815 FunctionDeductionHelper::StripSignature<decltype(&FP::operator())>::Sig
1816 >
1817function(FP) -> function<PROTOTYPE>;
1818
1819/// Deduce the template parameter `PROTOTYPE` from the signature of the
1820/// `operator()` of the functor supplied to the constructor of `function`.
1821template <
1822 class ALLOC,
1823 class FP,
1824 class PROTOTYPE = typename
1825 FunctionDeductionHelper::StripSignature<decltype(&FP::operator())>::Sig
1826 >
1827function(allocator_arg_t, ALLOC, FP) -> function<PROTOTYPE>;
1828#endif
1829
1830// FREE FUNCTIONS
1831template <class PROTOTYPE>
1832bool operator==(const function<PROTOTYPE>&, nullptr_t) BSLS_KEYWORD_NOEXCEPT;
1833
1834/// Return true if the `function` argument is empty, otherwise return false.
1835template <class PROTOTYPE>
1836bool operator==(nullptr_t, const function<PROTOTYPE>&) BSLS_KEYWORD_NOEXCEPT;
1837
1838template <class PROTOTYPE>
1839bool operator!=(const function<PROTOTYPE>&, nullptr_t) BSLS_KEYWORD_NOEXCEPT;
1840
1841/// Return false if the `function` argument is empty, otherwise return true.
1842template <class PROTOTYPE>
1843bool operator!=(nullptr_t, const function<PROTOTYPE>&) BSLS_KEYWORD_NOEXCEPT;
1844
1845/// Exchange the targets held by the specified `a` and specified `b` objects.
1846///
1847/// \pre The behavior is undefined unless 'a.get_allocator() ==
1848/// b.get_allocator()'.
1849template <class PROTOTYPE>
1850void swap(function<PROTOTYPE>& a,function<PROTOTYPE>& b) BSLS_KEYWORD_NOEXCEPT;
1851
1852} // close namespace bsl
1853
1854// ============================================================================
1855// TEMPLATE AND INLINE FUNCTION DEFINITIONS
1856// ============================================================================
1857
1858
1859
1860#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
1861// {{{ BEGIN GENERATED CODE
1862// Command line: sim_cpp11_features.py bslstl_function.h
1863#ifndef BSLSTL_FUNCTION_VARIADIC_LIMIT
1864#define BSLSTL_FUNCTION_VARIADIC_LIMIT 13
1865#endif
1866#ifndef BSLSTL_FUNCTION_VARIADIC_LIMIT_B
1867#define BSLSTL_FUNCTION_VARIADIC_LIMIT_B BSLSTL_FUNCTION_VARIADIC_LIMIT
1868#endif
1869
1870
1871#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 0
1872template <class RET>
1873inline
1875Function_Variadic(const allocator_type& allocator)
1876 : d_rep(allocator)
1877{
1878}
1879#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 0
1880
1881#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 1
1882template <class RET, class ARGS_01>
1883inline
1884bslstl::Function_Variadic<RET(ARGS_01)>::
1885Function_Variadic(const allocator_type& allocator)
1886 : d_rep(allocator)
1887{
1888}
1889#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 1
1890
1891#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 2
1892template <class RET, class ARGS_01,
1893 class ARGS_02>
1894inline
1895bslstl::Function_Variadic<RET(ARGS_01,
1896 ARGS_02)>::
1897Function_Variadic(const allocator_type& allocator)
1898 : d_rep(allocator)
1899{
1900}
1901#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 2
1902
1903#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 3
1904template <class RET, class ARGS_01,
1905 class ARGS_02,
1906 class ARGS_03>
1907inline
1908bslstl::Function_Variadic<RET(ARGS_01,
1909 ARGS_02,
1910 ARGS_03)>::
1911Function_Variadic(const allocator_type& allocator)
1912 : d_rep(allocator)
1913{
1914}
1915#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 3
1916
1917#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 4
1918template <class RET, class ARGS_01,
1919 class ARGS_02,
1920 class ARGS_03,
1921 class ARGS_04>
1922inline
1923bslstl::Function_Variadic<RET(ARGS_01,
1924 ARGS_02,
1925 ARGS_03,
1926 ARGS_04)>::
1927Function_Variadic(const allocator_type& allocator)
1928 : d_rep(allocator)
1929{
1930}
1931#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 4
1932
1933#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 5
1934template <class RET, class ARGS_01,
1935 class ARGS_02,
1936 class ARGS_03,
1937 class ARGS_04,
1938 class ARGS_05>
1939inline
1940bslstl::Function_Variadic<RET(ARGS_01,
1941 ARGS_02,
1942 ARGS_03,
1943 ARGS_04,
1944 ARGS_05)>::
1945Function_Variadic(const allocator_type& allocator)
1946 : d_rep(allocator)
1947{
1948}
1949#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 5
1950
1951#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 6
1952template <class RET, class ARGS_01,
1953 class ARGS_02,
1954 class ARGS_03,
1955 class ARGS_04,
1956 class ARGS_05,
1957 class ARGS_06>
1958inline
1959bslstl::Function_Variadic<RET(ARGS_01,
1960 ARGS_02,
1961 ARGS_03,
1962 ARGS_04,
1963 ARGS_05,
1964 ARGS_06)>::
1965Function_Variadic(const allocator_type& allocator)
1966 : d_rep(allocator)
1967{
1968}
1969#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 6
1970
1971#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 7
1972template <class RET, class ARGS_01,
1973 class ARGS_02,
1974 class ARGS_03,
1975 class ARGS_04,
1976 class ARGS_05,
1977 class ARGS_06,
1978 class ARGS_07>
1979inline
1980bslstl::Function_Variadic<RET(ARGS_01,
1981 ARGS_02,
1982 ARGS_03,
1983 ARGS_04,
1984 ARGS_05,
1985 ARGS_06,
1986 ARGS_07)>::
1987Function_Variadic(const allocator_type& allocator)
1988 : d_rep(allocator)
1989{
1990}
1991#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 7
1992
1993#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 8
1994template <class RET, class ARGS_01,
1995 class ARGS_02,
1996 class ARGS_03,
1997 class ARGS_04,
1998 class ARGS_05,
1999 class ARGS_06,
2000 class ARGS_07,
2001 class ARGS_08>
2002inline
2003bslstl::Function_Variadic<RET(ARGS_01,
2004 ARGS_02,
2005 ARGS_03,
2006 ARGS_04,
2007 ARGS_05,
2008 ARGS_06,
2009 ARGS_07,
2010 ARGS_08)>::
2011Function_Variadic(const allocator_type& allocator)
2012 : d_rep(allocator)
2013{
2014}
2015#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 8
2016
2017#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 9
2018template <class RET, class ARGS_01,
2019 class ARGS_02,
2020 class ARGS_03,
2021 class ARGS_04,
2022 class ARGS_05,
2023 class ARGS_06,
2024 class ARGS_07,
2025 class ARGS_08,
2026 class ARGS_09>
2027inline
2028bslstl::Function_Variadic<RET(ARGS_01,
2029 ARGS_02,
2030 ARGS_03,
2031 ARGS_04,
2032 ARGS_05,
2033 ARGS_06,
2034 ARGS_07,
2035 ARGS_08,
2036 ARGS_09)>::
2037Function_Variadic(const allocator_type& allocator)
2038 : d_rep(allocator)
2039{
2040}
2041#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 9
2042
2043#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 10
2044template <class RET, class ARGS_01,
2045 class ARGS_02,
2046 class ARGS_03,
2047 class ARGS_04,
2048 class ARGS_05,
2049 class ARGS_06,
2050 class ARGS_07,
2051 class ARGS_08,
2052 class ARGS_09,
2053 class ARGS_10>
2054inline
2055bslstl::Function_Variadic<RET(ARGS_01,
2056 ARGS_02,
2057 ARGS_03,
2058 ARGS_04,
2059 ARGS_05,
2060 ARGS_06,
2061 ARGS_07,
2062 ARGS_08,
2063 ARGS_09,
2064 ARGS_10)>::
2065Function_Variadic(const allocator_type& allocator)
2066 : d_rep(allocator)
2067{
2068}
2069#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 10
2070
2071#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 11
2072template <class RET, class ARGS_01,
2073 class ARGS_02,
2074 class ARGS_03,
2075 class ARGS_04,
2076 class ARGS_05,
2077 class ARGS_06,
2078 class ARGS_07,
2079 class ARGS_08,
2080 class ARGS_09,
2081 class ARGS_10,
2082 class ARGS_11>
2083inline
2084bslstl::Function_Variadic<RET(ARGS_01,
2085 ARGS_02,
2086 ARGS_03,
2087 ARGS_04,
2088 ARGS_05,
2089 ARGS_06,
2090 ARGS_07,
2091 ARGS_08,
2092 ARGS_09,
2093 ARGS_10,
2094 ARGS_11)>::
2095Function_Variadic(const allocator_type& allocator)
2096 : d_rep(allocator)
2097{
2098}
2099#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 11
2100
2101#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 12
2102template <class RET, class ARGS_01,
2103 class ARGS_02,
2104 class ARGS_03,
2105 class ARGS_04,
2106 class ARGS_05,
2107 class ARGS_06,
2108 class ARGS_07,
2109 class ARGS_08,
2110 class ARGS_09,
2111 class ARGS_10,
2112 class ARGS_11,
2113 class ARGS_12>
2114inline
2115bslstl::Function_Variadic<RET(ARGS_01,
2116 ARGS_02,
2117 ARGS_03,
2118 ARGS_04,
2119 ARGS_05,
2120 ARGS_06,
2121 ARGS_07,
2122 ARGS_08,
2123 ARGS_09,
2124 ARGS_10,
2125 ARGS_11,
2126 ARGS_12)>::
2127Function_Variadic(const allocator_type& allocator)
2128 : d_rep(allocator)
2129{
2130}
2131#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 12
2132
2133#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 13
2134template <class RET, class ARGS_01,
2135 class ARGS_02,
2136 class ARGS_03,
2137 class ARGS_04,
2138 class ARGS_05,
2139 class ARGS_06,
2140 class ARGS_07,
2141 class ARGS_08,
2142 class ARGS_09,
2143 class ARGS_10,
2144 class ARGS_11,
2145 class ARGS_12,
2146 class ARGS_13>
2147inline
2148bslstl::Function_Variadic<RET(ARGS_01,
2149 ARGS_02,
2150 ARGS_03,
2151 ARGS_04,
2152 ARGS_05,
2153 ARGS_06,
2154 ARGS_07,
2155 ARGS_08,
2156 ARGS_09,
2157 ARGS_10,
2158 ARGS_11,
2159 ARGS_12,
2160 ARGS_13)>::
2161Function_Variadic(const allocator_type& allocator)
2162 : d_rep(allocator)
2163{
2164}
2165#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 13
2166
2167
2168#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 0
2169template <class RET>
2170inline
2171RET bslstl::Function_Variadic<RET()>::operator()() const
2172{
2173 Invoker *invoker_p = reinterpret_cast<Invoker*>(d_rep.invoker());
2174
2175 if (! invoker_p) {
2177 }
2178
2179 return invoker_p(&d_rep);
2180}
2181#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 0
2182
2183#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 1
2184template <class RET, class ARGS_01>
2185inline
2186RET bslstl::Function_Variadic<RET(ARGS_01)>::operator()(ARGS_01 args_01) const
2187{
2188 Invoker *invoker_p = reinterpret_cast<Invoker*>(d_rep.invoker());
2189
2190 if (! invoker_p) {
2192 }
2193
2194 return invoker_p(&d_rep, args_01);
2195}
2196#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 1
2197
2198#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 2
2199template <class RET, class ARGS_01,
2200 class ARGS_02>
2201inline
2202RET bslstl::Function_Variadic<RET(ARGS_01,
2203 ARGS_02)>::operator()(ARGS_01 args_01,
2204 ARGS_02 args_02) const
2205{
2206 Invoker *invoker_p = reinterpret_cast<Invoker*>(d_rep.invoker());
2207
2208 if (! invoker_p) {
2210 }
2211
2212 return invoker_p(&d_rep, args_01,
2213 args_02);
2214}
2215#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 2
2216
2217#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 3
2218template <class RET, class ARGS_01,
2219 class ARGS_02,
2220 class ARGS_03>
2221inline
2222RET bslstl::Function_Variadic<RET(ARGS_01,
2223 ARGS_02,
2224 ARGS_03)>::operator()(ARGS_01 args_01,
2225 ARGS_02 args_02,
2226 ARGS_03 args_03) const
2227{
2228 Invoker *invoker_p = reinterpret_cast<Invoker*>(d_rep.invoker());
2229
2230 if (! invoker_p) {
2232 }
2233
2234 return invoker_p(&d_rep, args_01,
2235 args_02,
2236 args_03);
2237}
2238#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 3
2239
2240#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 4
2241template <class RET, class ARGS_01,
2242 class ARGS_02,
2243 class ARGS_03,
2244 class ARGS_04>
2245inline
2246RET bslstl::Function_Variadic<RET(ARGS_01,
2247 ARGS_02,
2248 ARGS_03,
2249 ARGS_04)>::operator()(ARGS_01 args_01,
2250 ARGS_02 args_02,
2251 ARGS_03 args_03,
2252 ARGS_04 args_04) const
2253{
2254 Invoker *invoker_p = reinterpret_cast<Invoker*>(d_rep.invoker());
2255
2256 if (! invoker_p) {
2258 }
2259
2260 return invoker_p(&d_rep, args_01,
2261 args_02,
2262 args_03,
2263 args_04);
2264}
2265#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 4
2266
2267#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 5
2268template <class RET, class ARGS_01,
2269 class ARGS_02,
2270 class ARGS_03,
2271 class ARGS_04,
2272 class ARGS_05>
2273inline
2274RET bslstl::Function_Variadic<RET(ARGS_01,
2275 ARGS_02,
2276 ARGS_03,
2277 ARGS_04,
2278 ARGS_05)>::operator()(ARGS_01 args_01,
2279 ARGS_02 args_02,
2280 ARGS_03 args_03,
2281 ARGS_04 args_04,
2282 ARGS_05 args_05) const
2283{
2284 Invoker *invoker_p = reinterpret_cast<Invoker*>(d_rep.invoker());
2285
2286 if (! invoker_p) {
2288 }
2289
2290 return invoker_p(&d_rep, args_01,
2291 args_02,
2292 args_03,
2293 args_04,
2294 args_05);
2295}
2296#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 5
2297
2298#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 6
2299template <class RET, class ARGS_01,
2300 class ARGS_02,
2301 class ARGS_03,
2302 class ARGS_04,
2303 class ARGS_05,
2304 class ARGS_06>
2305inline
2306RET bslstl::Function_Variadic<RET(ARGS_01,
2307 ARGS_02,
2308 ARGS_03,
2309 ARGS_04,
2310 ARGS_05,
2311 ARGS_06)>::operator()(ARGS_01 args_01,
2312 ARGS_02 args_02,
2313 ARGS_03 args_03,
2314 ARGS_04 args_04,
2315 ARGS_05 args_05,
2316 ARGS_06 args_06) const
2317{
2318 Invoker *invoker_p = reinterpret_cast<Invoker*>(d_rep.invoker());
2319
2320 if (! invoker_p) {
2322 }
2323
2324 return invoker_p(&d_rep, args_01,
2325 args_02,
2326 args_03,
2327 args_04,
2328 args_05,
2329 args_06);
2330}
2331#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 6
2332
2333#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 7
2334template <class RET, class ARGS_01,
2335 class ARGS_02,
2336 class ARGS_03,
2337 class ARGS_04,
2338 class ARGS_05,
2339 class ARGS_06,
2340 class ARGS_07>
2341inline
2342RET bslstl::Function_Variadic<RET(ARGS_01,
2343 ARGS_02,
2344 ARGS_03,
2345 ARGS_04,
2346 ARGS_05,
2347 ARGS_06,
2348 ARGS_07)>::operator()(ARGS_01 args_01,
2349 ARGS_02 args_02,
2350 ARGS_03 args_03,
2351 ARGS_04 args_04,
2352 ARGS_05 args_05,
2353 ARGS_06 args_06,
2354 ARGS_07 args_07) const
2355{
2356 Invoker *invoker_p = reinterpret_cast<Invoker*>(d_rep.invoker());
2357
2358 if (! invoker_p) {
2360 }
2361
2362 return invoker_p(&d_rep, args_01,
2363 args_02,
2364 args_03,
2365 args_04,
2366 args_05,
2367 args_06,
2368 args_07);
2369}
2370#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 7
2371
2372#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 8
2373template <class RET, class ARGS_01,
2374 class ARGS_02,
2375 class ARGS_03,
2376 class ARGS_04,
2377 class ARGS_05,
2378 class ARGS_06,
2379 class ARGS_07,
2380 class ARGS_08>
2381inline
2382RET bslstl::Function_Variadic<RET(ARGS_01,
2383 ARGS_02,
2384 ARGS_03,
2385 ARGS_04,
2386 ARGS_05,
2387 ARGS_06,
2388 ARGS_07,
2389 ARGS_08)>::operator()(ARGS_01 args_01,
2390 ARGS_02 args_02,
2391 ARGS_03 args_03,
2392 ARGS_04 args_04,
2393 ARGS_05 args_05,
2394 ARGS_06 args_06,
2395 ARGS_07 args_07,
2396 ARGS_08 args_08) const
2397{
2398 Invoker *invoker_p = reinterpret_cast<Invoker*>(d_rep.invoker());
2399
2400 if (! invoker_p) {
2402 }
2403
2404 return invoker_p(&d_rep, args_01,
2405 args_02,
2406 args_03,
2407 args_04,
2408 args_05,
2409 args_06,
2410 args_07,
2411 args_08);
2412}
2413#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 8
2414
2415#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 9
2416template <class RET, class ARGS_01,
2417 class ARGS_02,
2418 class ARGS_03,
2419 class ARGS_04,
2420 class ARGS_05,
2421 class ARGS_06,
2422 class ARGS_07,
2423 class ARGS_08,
2424 class ARGS_09>
2425inline
2426RET bslstl::Function_Variadic<RET(ARGS_01,
2427 ARGS_02,
2428 ARGS_03,
2429 ARGS_04,
2430 ARGS_05,
2431 ARGS_06,
2432 ARGS_07,
2433 ARGS_08,
2434 ARGS_09)>::operator()(ARGS_01 args_01,
2435 ARGS_02 args_02,
2436 ARGS_03 args_03,
2437 ARGS_04 args_04,
2438 ARGS_05 args_05,
2439 ARGS_06 args_06,
2440 ARGS_07 args_07,
2441 ARGS_08 args_08,
2442 ARGS_09 args_09) const
2443{
2444 Invoker *invoker_p = reinterpret_cast<Invoker*>(d_rep.invoker());
2445
2446 if (! invoker_p) {
2448 }
2449
2450 return invoker_p(&d_rep, args_01,
2451 args_02,
2452 args_03,
2453 args_04,
2454 args_05,
2455 args_06,
2456 args_07,
2457 args_08,
2458 args_09);
2459}
2460#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 9
2461
2462#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 10
2463template <class RET, class ARGS_01,
2464 class ARGS_02,
2465 class ARGS_03,
2466 class ARGS_04,
2467 class ARGS_05,
2468 class ARGS_06,
2469 class ARGS_07,
2470 class ARGS_08,
2471 class ARGS_09,
2472 class ARGS_10>
2473inline
2474RET bslstl::Function_Variadic<RET(ARGS_01,
2475 ARGS_02,
2476 ARGS_03,
2477 ARGS_04,
2478 ARGS_05,
2479 ARGS_06,
2480 ARGS_07,
2481 ARGS_08,
2482 ARGS_09,
2483 ARGS_10)>::operator()(ARGS_01 args_01,
2484 ARGS_02 args_02,
2485 ARGS_03 args_03,
2486 ARGS_04 args_04,
2487 ARGS_05 args_05,
2488 ARGS_06 args_06,
2489 ARGS_07 args_07,
2490 ARGS_08 args_08,
2491 ARGS_09 args_09,
2492 ARGS_10 args_10) const
2493{
2494 Invoker *invoker_p = reinterpret_cast<Invoker*>(d_rep.invoker());
2495
2496 if (! invoker_p) {
2498 }
2499
2500 return invoker_p(&d_rep, args_01,
2501 args_02,
2502 args_03,
2503 args_04,
2504 args_05,
2505 args_06,
2506 args_07,
2507 args_08,
2508 args_09,
2509 args_10);
2510}
2511#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 10
2512
2513#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 11
2514template <class RET, class ARGS_01,
2515 class ARGS_02,
2516 class ARGS_03,
2517 class ARGS_04,
2518 class ARGS_05,
2519 class ARGS_06,
2520 class ARGS_07,
2521 class ARGS_08,
2522 class ARGS_09,
2523 class ARGS_10,
2524 class ARGS_11>
2525inline
2526RET bslstl::Function_Variadic<RET(ARGS_01,
2527 ARGS_02,
2528 ARGS_03,
2529 ARGS_04,
2530 ARGS_05,
2531 ARGS_06,
2532 ARGS_07,
2533 ARGS_08,
2534 ARGS_09,
2535 ARGS_10,
2536 ARGS_11)>::operator()(ARGS_01 args_01,
2537 ARGS_02 args_02,
2538 ARGS_03 args_03,
2539 ARGS_04 args_04,
2540 ARGS_05 args_05,
2541 ARGS_06 args_06,
2542 ARGS_07 args_07,
2543 ARGS_08 args_08,
2544 ARGS_09 args_09,
2545 ARGS_10 args_10,
2546 ARGS_11 args_11) const
2547{
2548 Invoker *invoker_p = reinterpret_cast<Invoker*>(d_rep.invoker());
2549
2550 if (! invoker_p) {
2552 }
2553
2554 return invoker_p(&d_rep, args_01,
2555 args_02,
2556 args_03,
2557 args_04,
2558 args_05,
2559 args_06,
2560 args_07,
2561 args_08,
2562 args_09,
2563 args_10,
2564 args_11);
2565}
2566#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 11
2567
2568#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 12
2569template <class RET, class ARGS_01,
2570 class ARGS_02,
2571 class ARGS_03,
2572 class ARGS_04,
2573 class ARGS_05,
2574 class ARGS_06,
2575 class ARGS_07,
2576 class ARGS_08,
2577 class ARGS_09,
2578 class ARGS_10,
2579 class ARGS_11,
2580 class ARGS_12>
2581inline
2582RET bslstl::Function_Variadic<RET(ARGS_01,
2583 ARGS_02,
2584 ARGS_03,
2585 ARGS_04,
2586 ARGS_05,
2587 ARGS_06,
2588 ARGS_07,
2589 ARGS_08,
2590 ARGS_09,
2591 ARGS_10,
2592 ARGS_11,
2593 ARGS_12)>::operator()(ARGS_01 args_01,
2594 ARGS_02 args_02,
2595 ARGS_03 args_03,
2596 ARGS_04 args_04,
2597 ARGS_05 args_05,
2598 ARGS_06 args_06,
2599 ARGS_07 args_07,
2600 ARGS_08 args_08,
2601 ARGS_09 args_09,
2602 ARGS_10 args_10,
2603 ARGS_11 args_11,
2604 ARGS_12 args_12) const
2605{
2606 Invoker *invoker_p = reinterpret_cast<Invoker*>(d_rep.invoker());
2607
2608 if (! invoker_p) {
2610 }
2611
2612 return invoker_p(&d_rep, args_01,
2613 args_02,
2614 args_03,
2615 args_04,
2616 args_05,
2617 args_06,
2618 args_07,
2619 args_08,
2620 args_09,
2621 args_10,
2622 args_11,
2623 args_12);
2624}
2625#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 12
2626
2627#if BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 13
2628template <class RET, class ARGS_01,
2629 class ARGS_02,
2630 class ARGS_03,
2631 class ARGS_04,
2632 class ARGS_05,
2633 class ARGS_06,
2634 class ARGS_07,
2635 class ARGS_08,
2636 class ARGS_09,
2637 class ARGS_10,
2638 class ARGS_11,
2639 class ARGS_12,
2640 class ARGS_13>
2641inline
2642RET bslstl::Function_Variadic<RET(ARGS_01,
2643 ARGS_02,
2644 ARGS_03,
2645 ARGS_04,
2646 ARGS_05,
2647 ARGS_06,
2648 ARGS_07,
2649 ARGS_08,
2650 ARGS_09,
2651 ARGS_10,
2652 ARGS_11,
2653 ARGS_12,
2654 ARGS_13)>::operator()(ARGS_01 args_01,
2655 ARGS_02 args_02,
2656 ARGS_03 args_03,
2657 ARGS_04 args_04,
2658 ARGS_05 args_05,
2659 ARGS_06 args_06,
2660 ARGS_07 args_07,
2661 ARGS_08 args_08,
2662 ARGS_09 args_09,
2663 ARGS_10 args_10,
2664 ARGS_11 args_11,
2665 ARGS_12 args_12,
2666 ARGS_13 args_13) const
2667{
2668 Invoker *invoker_p = reinterpret_cast<Invoker*>(d_rep.invoker());
2669
2670 if (! invoker_p) {
2672 }
2673
2674 return invoker_p(&d_rep, args_01,
2675 args_02,
2676 args_03,
2677 args_04,
2678 args_05,
2679 args_06,
2680 args_07,
2681 args_08,
2682 args_09,
2683 args_10,
2684 args_11,
2685 args_12,
2686 args_13);
2687}
2688#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_B >= 13
2689
2690#else
2691// The generated code below is a workaround for the absence of perfect
2692// forwarding in some compilers.
2693
2694
2695template <class RET, class... ARGS>
2696inline
2697bslstl::Function_Variadic<RET(ARGS...)>::
2698Function_Variadic(const allocator_type& allocator)
2699 : d_rep(allocator)
2700{
2701}
2702
2703template <class RET, class... ARGS>
2704inline
2705RET bslstl::Function_Variadic<RET(ARGS...)>::operator()(ARGS... args) const
2706{
2707 Invoker *invoker_p = reinterpret_cast<Invoker*>(d_rep.invoker());
2708
2709 if (! invoker_p) {
2711 }
2712
2713 return invoker_p(&d_rep, args...);
2714}
2715
2716// }}} END GENERATED CODE
2717#endif
2718
2719namespace bslstl {
2720
2721#if BSLS_COMPILERFEATURES_SIMULATE_VARIADIC_TEMPLATES
2722// {{{ BEGIN GENERATED CODE
2723// Command line: sim_cpp11_features.py bslstl_function.h
2724#ifndef BSLSTL_FUNCTION_VARIADIC_LIMIT
2725#define BSLSTL_FUNCTION_VARIADIC_LIMIT 13
2726#endif
2727#ifndef BSLSTL_FUNCTION_VARIADIC_LIMIT_C
2728#define BSLSTL_FUNCTION_VARIADIC_LIMIT_C BSLSTL_FUNCTION_VARIADIC_LIMIT
2729#endif
2730
2731
2732#ifdef BSLSTL_FUNCTION_INVOKERUTIL_SUPPORT_IS_FUNC_INVOCABLE
2733
2734#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 0
2735template <class RET, class FUNC>
2736struct Function_IsInvocableWithPrototype<RET(), FUNC>
2737: Function_InvokerUtil::IsFuncInvocable<RET(), FUNC> {
2738};
2739#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 0
2740
2741#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 1
2742template <class RET, class FUNC, class ARGS_01>
2743struct Function_IsInvocableWithPrototype<RET(ARGS_01), FUNC>
2744: Function_InvokerUtil::IsFuncInvocable<RET(ARGS_01), FUNC> {
2745};
2746#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 1
2747
2748#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 2
2749template <class RET, class FUNC, class ARGS_01,
2750 class ARGS_02>
2751struct Function_IsInvocableWithPrototype<RET(ARGS_01,
2752 ARGS_02), FUNC>
2753: Function_InvokerUtil::IsFuncInvocable<RET(ARGS_01,
2754 ARGS_02), FUNC> {
2755};
2756#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 2
2757
2758#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 3
2759template <class RET, class FUNC, class ARGS_01,
2760 class ARGS_02,
2761 class ARGS_03>
2762struct Function_IsInvocableWithPrototype<RET(ARGS_01,
2763 ARGS_02,
2764 ARGS_03), FUNC>
2765: Function_InvokerUtil::IsFuncInvocable<RET(ARGS_01,
2766 ARGS_02,
2767 ARGS_03), FUNC> {
2768};
2769#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 3
2770
2771#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 4
2772template <class RET, class FUNC, class ARGS_01,
2773 class ARGS_02,
2774 class ARGS_03,
2775 class ARGS_04>
2776struct Function_IsInvocableWithPrototype<RET(ARGS_01,
2777 ARGS_02,
2778 ARGS_03,
2779 ARGS_04), FUNC>
2780: Function_InvokerUtil::IsFuncInvocable<RET(ARGS_01,
2781 ARGS_02,
2782 ARGS_03,
2783 ARGS_04), FUNC> {
2784};
2785#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 4
2786
2787#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 5
2788template <class RET, class FUNC, class ARGS_01,
2789 class ARGS_02,
2790 class ARGS_03,
2791 class ARGS_04,
2792 class ARGS_05>
2793struct Function_IsInvocableWithPrototype<RET(ARGS_01,
2794 ARGS_02,
2795 ARGS_03,
2796 ARGS_04,
2797 ARGS_05), FUNC>
2798: Function_InvokerUtil::IsFuncInvocable<RET(ARGS_01,
2799 ARGS_02,
2800 ARGS_03,
2801 ARGS_04,
2802 ARGS_05), FUNC> {
2803};
2804#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 5
2805
2806#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 6
2807template <class RET, class FUNC, class ARGS_01,
2808 class ARGS_02,
2809 class ARGS_03,
2810 class ARGS_04,
2811 class ARGS_05,
2812 class ARGS_06>
2813struct Function_IsInvocableWithPrototype<RET(ARGS_01,
2814 ARGS_02,
2815 ARGS_03,
2816 ARGS_04,
2817 ARGS_05,
2818 ARGS_06), FUNC>
2819: Function_InvokerUtil::IsFuncInvocable<RET(ARGS_01,
2820 ARGS_02,
2821 ARGS_03,
2822 ARGS_04,
2823 ARGS_05,
2824 ARGS_06), FUNC> {
2825};
2826#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 6
2827
2828#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 7
2829template <class RET, class FUNC, class ARGS_01,
2830 class ARGS_02,
2831 class ARGS_03,
2832 class ARGS_04,
2833 class ARGS_05,
2834 class ARGS_06,
2835 class ARGS_07>
2836struct Function_IsInvocableWithPrototype<RET(ARGS_01,
2837 ARGS_02,
2838 ARGS_03,
2839 ARGS_04,
2840 ARGS_05,
2841 ARGS_06,
2842 ARGS_07), FUNC>
2843: Function_InvokerUtil::IsFuncInvocable<RET(ARGS_01,
2844 ARGS_02,
2845 ARGS_03,
2846 ARGS_04,
2847 ARGS_05,
2848 ARGS_06,
2849 ARGS_07), FUNC> {
2850};
2851#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 7
2852
2853#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 8
2854template <class RET, class FUNC, class ARGS_01,
2855 class ARGS_02,
2856 class ARGS_03,
2857 class ARGS_04,
2858 class ARGS_05,
2859 class ARGS_06,
2860 class ARGS_07,
2861 class ARGS_08>
2862struct Function_IsInvocableWithPrototype<RET(ARGS_01,
2863 ARGS_02,
2864 ARGS_03,
2865 ARGS_04,
2866 ARGS_05,
2867 ARGS_06,
2868 ARGS_07,
2869 ARGS_08), FUNC>
2870: Function_InvokerUtil::IsFuncInvocable<RET(ARGS_01,
2871 ARGS_02,
2872 ARGS_03,
2873 ARGS_04,
2874 ARGS_05,
2875 ARGS_06,
2876 ARGS_07,
2877 ARGS_08), FUNC> {
2878};
2879#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 8
2880
2881#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 9
2882template <class RET, class FUNC, class ARGS_01,
2883 class ARGS_02,
2884 class ARGS_03,
2885 class ARGS_04,
2886 class ARGS_05,
2887 class ARGS_06,
2888 class ARGS_07,
2889 class ARGS_08,
2890 class ARGS_09>
2891struct Function_IsInvocableWithPrototype<RET(ARGS_01,
2892 ARGS_02,
2893 ARGS_03,
2894 ARGS_04,
2895 ARGS_05,
2896 ARGS_06,
2897 ARGS_07,
2898 ARGS_08,
2899 ARGS_09), FUNC>
2900: Function_InvokerUtil::IsFuncInvocable<RET(ARGS_01,
2901 ARGS_02,
2902 ARGS_03,
2903 ARGS_04,
2904 ARGS_05,
2905 ARGS_06,
2906 ARGS_07,
2907 ARGS_08,
2908 ARGS_09), FUNC> {
2909};
2910#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 9
2911
2912#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 10
2913template <class RET, class FUNC, class ARGS_01,
2914 class ARGS_02,
2915 class ARGS_03,
2916 class ARGS_04,
2917 class ARGS_05,
2918 class ARGS_06,
2919 class ARGS_07,
2920 class ARGS_08,
2921 class ARGS_09,
2922 class ARGS_10>
2923struct Function_IsInvocableWithPrototype<RET(ARGS_01,
2924 ARGS_02,
2925 ARGS_03,
2926 ARGS_04,
2927 ARGS_05,
2928 ARGS_06,
2929 ARGS_07,
2930 ARGS_08,
2931 ARGS_09,
2932 ARGS_10), FUNC>
2933: Function_InvokerUtil::IsFuncInvocable<RET(ARGS_01,
2934 ARGS_02,
2935 ARGS_03,
2936 ARGS_04,
2937 ARGS_05,
2938 ARGS_06,
2939 ARGS_07,
2940 ARGS_08,
2941 ARGS_09,
2942 ARGS_10), FUNC> {
2943};
2944#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 10
2945
2946#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 11
2947template <class RET, class FUNC, class ARGS_01,
2948 class ARGS_02,
2949 class ARGS_03,
2950 class ARGS_04,
2951 class ARGS_05,
2952 class ARGS_06,
2953 class ARGS_07,
2954 class ARGS_08,
2955 class ARGS_09,
2956 class ARGS_10,
2957 class ARGS_11>
2958struct Function_IsInvocableWithPrototype<RET(ARGS_01,
2959 ARGS_02,
2960 ARGS_03,
2961 ARGS_04,
2962 ARGS_05,
2963 ARGS_06,
2964 ARGS_07,
2965 ARGS_08,
2966 ARGS_09,
2967 ARGS_10,
2968 ARGS_11), FUNC>
2969: Function_InvokerUtil::IsFuncInvocable<RET(ARGS_01,
2970 ARGS_02,
2971 ARGS_03,
2972 ARGS_04,
2973 ARGS_05,
2974 ARGS_06,
2975 ARGS_07,
2976 ARGS_08,
2977 ARGS_09,
2978 ARGS_10,
2979 ARGS_11), FUNC> {
2980};
2981#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 11
2982
2983#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 12
2984template <class RET, class FUNC, class ARGS_01,
2985 class ARGS_02,
2986 class ARGS_03,
2987 class ARGS_04,
2988 class ARGS_05,
2989 class ARGS_06,
2990 class ARGS_07,
2991 class ARGS_08,
2992 class ARGS_09,
2993 class ARGS_10,
2994 class ARGS_11,
2995 class ARGS_12>
2996struct Function_IsInvocableWithPrototype<RET(ARGS_01,
2997 ARGS_02,
2998 ARGS_03,
2999 ARGS_04,
3000 ARGS_05,
3001 ARGS_06,
3002 ARGS_07,
3003 ARGS_08,
3004 ARGS_09,
3005 ARGS_10,
3006 ARGS_11,
3007 ARGS_12), FUNC>
3008: Function_InvokerUtil::IsFuncInvocable<RET(ARGS_01,
3009 ARGS_02,
3010 ARGS_03,
3011 ARGS_04,
3012 ARGS_05,
3013 ARGS_06,
3014 ARGS_07,
3015 ARGS_08,
3016 ARGS_09,
3017 ARGS_10,
3018 ARGS_11,
3019 ARGS_12), FUNC> {
3020};
3021#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 12
3022
3023#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 13
3024template <class RET, class FUNC, class ARGS_01,
3025 class ARGS_02,
3026 class ARGS_03,
3027 class ARGS_04,
3028 class ARGS_05,
3029 class ARGS_06,
3030 class ARGS_07,
3031 class ARGS_08,
3032 class ARGS_09,
3033 class ARGS_10,
3034 class ARGS_11,
3035 class ARGS_12,
3036 class ARGS_13>
3037struct Function_IsInvocableWithPrototype<RET(ARGS_01,
3038 ARGS_02,
3039 ARGS_03,
3040 ARGS_04,
3041 ARGS_05,
3042 ARGS_06,
3043 ARGS_07,
3044 ARGS_08,
3045 ARGS_09,
3046 ARGS_10,
3047 ARGS_11,
3048 ARGS_12,
3049 ARGS_13), FUNC>
3050: Function_InvokerUtil::IsFuncInvocable<RET(ARGS_01,
3051 ARGS_02,
3052 ARGS_03,
3053 ARGS_04,
3054 ARGS_05,
3055 ARGS_06,
3056 ARGS_07,
3057 ARGS_08,
3058 ARGS_09,
3059 ARGS_10,
3060 ARGS_11,
3061 ARGS_12,
3062 ARGS_13), FUNC> {
3063};
3064#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 13
3065
3066
3067#else
3068
3069#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 0
3070template <class RET, class FUNC>
3071struct Function_IsInvocableWithPrototype<RET(), FUNC>
3072: bsl::integral_constant<bool, !bsl::is_integral<FUNC>::value> {
3073};
3074#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 0
3075
3076#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 1
3077template <class RET, class FUNC, class ARGS_01>
3078struct Function_IsInvocableWithPrototype<RET(ARGS_01), FUNC>
3079: bsl::integral_constant<bool, !bsl::is_integral<FUNC>::value> {
3080};
3081#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 1
3082
3083#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 2
3084template <class RET, class FUNC, class ARGS_01,
3085 class ARGS_02>
3086struct Function_IsInvocableWithPrototype<RET(ARGS_01,
3087 ARGS_02), FUNC>
3088: bsl::integral_constant<bool, !bsl::is_integral<FUNC>::value> {
3089};
3090#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 2
3091
3092#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 3
3093template <class RET, class FUNC, class ARGS_01,
3094 class ARGS_02,
3095 class ARGS_03>
3096struct Function_IsInvocableWithPrototype<RET(ARGS_01,
3097 ARGS_02,
3098 ARGS_03), FUNC>
3099: bsl::integral_constant<bool, !bsl::is_integral<FUNC>::value> {
3100};
3101#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 3
3102
3103#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 4
3104template <class RET, class FUNC, class ARGS_01,
3105 class ARGS_02,
3106 class ARGS_03,
3107 class ARGS_04>
3108struct Function_IsInvocableWithPrototype<RET(ARGS_01,
3109 ARGS_02,
3110 ARGS_03,
3111 ARGS_04), FUNC>
3112: bsl::integral_constant<bool, !bsl::is_integral<FUNC>::value> {
3113};
3114#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 4
3115
3116#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 5
3117template <class RET, class FUNC, class ARGS_01,
3118 class ARGS_02,
3119 class ARGS_03,
3120 class ARGS_04,
3121 class ARGS_05>
3122struct Function_IsInvocableWithPrototype<RET(ARGS_01,
3123 ARGS_02,
3124 ARGS_03,
3125 ARGS_04,
3126 ARGS_05), FUNC>
3127: bsl::integral_constant<bool, !bsl::is_integral<FUNC>::value> {
3128};
3129#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 5
3130
3131#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 6
3132template <class RET, class FUNC, class ARGS_01,
3133 class ARGS_02,
3134 class ARGS_03,
3135 class ARGS_04,
3136 class ARGS_05,
3137 class ARGS_06>
3138struct Function_IsInvocableWithPrototype<RET(ARGS_01,
3139 ARGS_02,
3140 ARGS_03,
3141 ARGS_04,
3142 ARGS_05,
3143 ARGS_06), FUNC>
3144: bsl::integral_constant<bool, !bsl::is_integral<FUNC>::value> {
3145};
3146#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 6
3147
3148#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 7
3149template <class RET, class FUNC, class ARGS_01,
3150 class ARGS_02,
3151 class ARGS_03,
3152 class ARGS_04,
3153 class ARGS_05,
3154 class ARGS_06,
3155 class ARGS_07>
3156struct Function_IsInvocableWithPrototype<RET(ARGS_01,
3157 ARGS_02,
3158 ARGS_03,
3159 ARGS_04,
3160 ARGS_05,
3161 ARGS_06,
3162 ARGS_07), FUNC>
3163: bsl::integral_constant<bool, !bsl::is_integral<FUNC>::value> {
3164};
3165#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 7
3166
3167#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 8
3168template <class RET, class FUNC, class ARGS_01,
3169 class ARGS_02,
3170 class ARGS_03,
3171 class ARGS_04,
3172 class ARGS_05,
3173 class ARGS_06,
3174 class ARGS_07,
3175 class ARGS_08>
3176struct Function_IsInvocableWithPrototype<RET(ARGS_01,
3177 ARGS_02,
3178 ARGS_03,
3179 ARGS_04,
3180 ARGS_05,
3181 ARGS_06,
3182 ARGS_07,
3183 ARGS_08), FUNC>
3184: bsl::integral_constant<bool, !bsl::is_integral<FUNC>::value> {
3185};
3186#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 8
3187
3188#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 9
3189template <class RET, class FUNC, class ARGS_01,
3190 class ARGS_02,
3191 class ARGS_03,
3192 class ARGS_04,
3193 class ARGS_05,
3194 class ARGS_06,
3195 class ARGS_07,
3196 class ARGS_08,
3197 class ARGS_09>
3198struct Function_IsInvocableWithPrototype<RET(ARGS_01,
3199 ARGS_02,
3200 ARGS_03,
3201 ARGS_04,
3202 ARGS_05,
3203 ARGS_06,
3204 ARGS_07,
3205 ARGS_08,
3206 ARGS_09), FUNC>
3207: bsl::integral_constant<bool, !bsl::is_integral<FUNC>::value> {
3208};
3209#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 9
3210
3211#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 10
3212template <class RET, class FUNC, class ARGS_01,
3213 class ARGS_02,
3214 class ARGS_03,
3215 class ARGS_04,
3216 class ARGS_05,
3217 class ARGS_06,
3218 class ARGS_07,
3219 class ARGS_08,
3220 class ARGS_09,
3221 class ARGS_10>
3222struct Function_IsInvocableWithPrototype<RET(ARGS_01,
3223 ARGS_02,
3224 ARGS_03,
3225 ARGS_04,
3226 ARGS_05,
3227 ARGS_06,
3228 ARGS_07,
3229 ARGS_08,
3230 ARGS_09,
3231 ARGS_10), FUNC>
3232: bsl::integral_constant<bool, !bsl::is_integral<FUNC>::value> {
3233};
3234#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 10
3235
3236#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 11
3237template <class RET, class FUNC, class ARGS_01,
3238 class ARGS_02,
3239 class ARGS_03,
3240 class ARGS_04,
3241 class ARGS_05,
3242 class ARGS_06,
3243 class ARGS_07,
3244 class ARGS_08,
3245 class ARGS_09,
3246 class ARGS_10,
3247 class ARGS_11>
3248struct Function_IsInvocableWithPrototype<RET(ARGS_01,
3249 ARGS_02,
3250 ARGS_03,
3251 ARGS_04,
3252 ARGS_05,
3253 ARGS_06,
3254 ARGS_07,
3255 ARGS_08,
3256 ARGS_09,
3257 ARGS_10,
3258 ARGS_11), FUNC>
3259: bsl::integral_constant<bool, !bsl::is_integral<FUNC>::value> {
3260};
3261#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 11
3262
3263#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 12
3264template <class RET, class FUNC, class ARGS_01,
3265 class ARGS_02,
3266 class ARGS_03,
3267 class ARGS_04,
3268 class ARGS_05,
3269 class ARGS_06,
3270 class ARGS_07,
3271 class ARGS_08,
3272 class ARGS_09,
3273 class ARGS_10,
3274 class ARGS_11,
3275 class ARGS_12>
3276struct Function_IsInvocableWithPrototype<RET(ARGS_01,
3277 ARGS_02,
3278 ARGS_03,
3279 ARGS_04,
3280 ARGS_05,
3281 ARGS_06,
3282 ARGS_07,
3283 ARGS_08,
3284 ARGS_09,
3285 ARGS_10,
3286 ARGS_11,
3287 ARGS_12), FUNC>
3288: bsl::integral_constant<bool, !bsl::is_integral<FUNC>::value> {
3289};
3290#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 12
3291
3292#if BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 13
3293template <class RET, class FUNC, class ARGS_01,
3294 class ARGS_02,
3295 class ARGS_03,
3296 class ARGS_04,
3297 class ARGS_05,
3298 class ARGS_06,
3299 class ARGS_07,
3300 class ARGS_08,
3301 class ARGS_09,
3302 class ARGS_10,
3303 class ARGS_11,
3304 class ARGS_12,
3305 class ARGS_13>
3306struct Function_IsInvocableWithPrototype<RET(ARGS_01,
3307 ARGS_02,
3308 ARGS_03,
3309 ARGS_04,
3310 ARGS_05,
3311 ARGS_06,
3312 ARGS_07,
3313 ARGS_08,
3314 ARGS_09,
3315 ARGS_10,
3316 ARGS_11,
3317 ARGS_12,
3318 ARGS_13), FUNC>
3319: bsl::integral_constant<bool, !bsl::is_integral<FUNC>::value> {
3320};
3321#endif // BSLSTL_FUNCTION_VARIADIC_LIMIT_C >= 13
3322
3323
3324#endif
3325#else
3326// The generated code below is a workaround for the absence of perfect
3327// forwarding in some compilers.
3328
3329
3330#ifdef BSLSTL_FUNCTION_INVOKERUTIL_SUPPORT_IS_FUNC_INVOCABLE
3331
3332template <class RET, class FUNC, class... ARGS>
3333struct Function_IsInvocableWithPrototype<RET(ARGS...), FUNC>
3334: Function_InvokerUtil::IsFuncInvocable<RET(ARGS...), FUNC> {
3335};
3336
3337#else
3338
3339template <class RET, class FUNC, class... ARGS>
3340struct Function_IsInvocableWithPrototype<RET(ARGS...), FUNC>
3341: bsl::integral_constant<bool, !bsl::is_integral<FUNC>::value> {
3342};
3343
3344#endif
3345// }}} END GENERATED CODE
3346#endif
3347
3348} // close package namespace
3349
3350
3351 // ----------------------------
3352 // class template bsl::function
3353 // ----------------------------
3354
3355// PRIVATE MANIPULATORS
3356template <class PROTOTYPE>
3357template <class FUNC>
3358inline
3361{
3362 typedef BloombergLP::bslstl::Function_InvokerUtil InvokerUtil;
3363 typedef InvokerUtil::GenericInvoker GenericInvoker;
3364 typedef typename Decay<FUNC>::type DecayedFunc;
3365
3366 const DecayedFunc& decayedFunc = func; // Force function-to-pointer decay.
3367 GenericInvoker *const invoker =
3368 InvokerUtil::invokerForFunc<PROTOTYPE>(decayedFunc);
3369
3370 this->d_rep.installFunc(BSLS_COMPILERFEATURES_FORWARD(FUNC, func),
3371 invoker);
3372}
3373
3374// CREATORS
3375template <class PROTOTYPE>
3377 : Base(allocator_type())
3378{
3379}
3380
3381template <class PROTOTYPE>
3383 : Base(allocator_type())
3384{
3385}
3386
3387template <class PROTOTYPE>
3388inline
3389bsl::function<PROTOTYPE>::function(allocator_arg_t ,
3390 const allocator_type& allocator)
3392 : Base(allocator)
3393{
3394}
3395
3396template <class PROTOTYPE>
3397inline
3398bsl::function<PROTOTYPE>::function(allocator_arg_t ,
3399 const allocator_type& allocator,
3400 nullptr_t) BSLS_KEYWORD_NOEXCEPT
3401 : Base(allocator)
3402{
3403}
3404
3405template <class PROTOTYPE>
3406inline bsl::function<PROTOTYPE>::function(const function& original)
3407 : Base(allocator_type())
3408{
3409 this->d_rep.copyInit(original.d_rep);
3410}
3411
3412template <class PROTOTYPE>
3413inline bsl::function<PROTOTYPE>::function(allocator_arg_t,
3414 const allocator_type& allocator,
3415 const function& original)
3416 : Base(allocator)
3417{
3418 this->d_rep.copyInit(original.d_rep);
3419}
3420
3421template <class PROTOTYPE>
3422inline
3424 BloombergLP::bslmf::MovableRef<function> original) BSLS_KEYWORD_NOEXCEPT
3425 : Base(MovableRefUtil::access(original).get_allocator())
3426{
3427 this->d_rep.moveInit(&MovableRefUtil::access(original).d_rep);
3428}
3429
3430template <class PROTOTYPE>
3432 allocator_arg_t,
3433 const allocator_type& allocator,
3434 BloombergLP::bslmf::MovableRef<function> original)
3435 : Base(allocator)
3436{
3437 this->d_rep.moveInit(&MovableRefUtil::access(original).d_rep);
3438}
3439
3440// MANIPULATORS
3441template <class PROTOTYPE>
3443bsl::function<PROTOTYPE>::operator=(const function& rhs)
3444{
3445 function temp(allocator_arg, this->get_allocator(), rhs);
3446 this->d_rep.makeEmpty(); // Won't throw
3447 this->d_rep.moveInit(&temp.d_rep); // Won't throw
3448 return *this;
3449}
3450
3451template <class PROTOTYPE>
3454 BloombergLP::bslmf::MovableRef<function> rhs)
3455{
3456 function temp(allocator_arg, this->get_allocator(),
3457 MovableRefUtil::move(rhs));
3458 this->d_rep.makeEmpty(); // Won't throw
3459 this->d_rep.moveInit(&temp.d_rep); // Won't throw
3460 return *this;
3461}
3462
3463template <class PROTOTYPE>
3466{
3467 this->d_rep.makeEmpty();
3468 return *this;
3469}
3470
3471template <class PROTOTYPE>
3472inline
3474{
3475 this->d_rep.swap(other.d_rep); // Won't throw
3476}
3477
3478template <class PROTOTYPE>
3479template<class TP>
3480inline
3482{
3483 return this->d_rep.template target<TP>();
3484}
3485
3486// ACCESSORS
3487
3488#ifdef BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
3489template <class PROTOTYPE>
3490inline
3492{
3493 // If there is an invoker, then this function is non-empty (return true);
3494 // otherwise it is empty (return false).
3495 return 0 != this->d_rep.invoker();
3496}
3497#endif // BSLS_COMPILERFEATURES_SUPPORT_OPERATOR_EXPLICIT
3498
3499template <class PROTOTYPE>
3500inline
3503{
3504 return this->d_rep.get_allocator();
3505}
3506
3507template <class PROTOTYPE>
3508template<class TP>
3509inline
3511{
3512 return this->d_rep.template target<TP>();
3513}
3514
3515template <class PROTOTYPE>
3516const std::type_info&
3518{
3519 return this->d_rep.target_type();
3520}
3521
3522#ifndef BDE_OMIT_INTERNAL_DEPRECATED
3523// CONVERSIONS TO LEGACY TYPE
3524template <class PROTOTYPE>
3525inline
3526bsl::function<PROTOTYPE>::operator BloombergLP::bdef_Function<PROTOTYPE *>&()
3528{
3529 typedef BloombergLP::bdef_Function<PROTOTYPE *> Ret;
3530 return *static_cast<Ret*>(this);
3531}
3532
3533template <class PROTOTYPE>
3534inline
3536operator const BloombergLP::bdef_Function<PROTOTYPE *>&() const
3538{
3539 typedef const BloombergLP::bdef_Function<PROTOTYPE *> Ret;
3540 return *static_cast<Ret*>(this);
3541}
3542
3543template <class PROTOTYPE>
3544inline
3545BloombergLP::bslma::Allocator *
3547{
3548 return get_allocator().mechanism();
3549}
3550
3551template <class PROTOTYPE>
3552inline
3554{
3555 return this->d_rep.isInplace();
3556}
3557#endif // BDE_OMIT_INTERNAL_DEPRECATED
3558
3559// FREE FUNCTIONS
3560template <class PROTOTYPE>
3561inline
3564{
3565 return !f;
3566}
3567
3568template <class PROTOTYPE>
3569inline
3572{
3573 return !f;
3574}
3575
3576template <class PROTOTYPE>
3577inline
3580{
3581 return !!f;
3582}
3583
3584template <class PROTOTYPE>
3585inline
3588{
3589 return !!f;
3590}
3591
3592template <class PROTOTYPE>
3593inline
3596{
3597 a.swap(b);
3598}
3599
3600 // --------------------------------------------------------------
3601 // specialization of class template Function_InvokerUtil_Dispatch
3602 // --------------------------------------------------------------
3603
3604
3605namespace bslstl {
3606
3607/// Specialization of null checker for instantiations of `bsl::function`.
3608/// This specialization treats an empty `bsl::function` as a null object.
3609template <class PROTO>
3610struct Function_InvokerUtilNullCheck<bsl::function<PROTO> > {
3611
3612 // CLASS METHODS
3613
3614 /// Return true if the `bsl::function` specified by `f` is empty; else
3615 /// false.
3616 static bool isNull(const bsl::function<PROTO>& f)
3617 {
3618 return !f;
3619 }
3620};
3621
3622} // close package namespace
3623
3624
3625// Undo `BSLS_ASSERT` filename fix -- See @ref bsls_assertimputil
3626#ifdef BSLS_ASSERTIMPUTIL_AVOID_STRING_CONSTANTS
3627#undef BSLS_ASSERTIMPUTIL_FILE
3628#define BSLS_ASSERTIMPUTIL_FILE BSLS_ASSERTIMPUTIL_DEFAULTFILE
3629#endif
3630
3631#else // if ! defined(DEFINED_BSLSTL_FUNCTION_H)
3632# error Not valid except when included from bslstl_function.h
3633#endif // ! defined(COMPILING_BSLSTL_FUNCTION_H)
3634
3635#endif // ! defined(INCLUDED_BSLSTL_FUNCTION_CPP03)
3636
3637// ----------------------------------------------------------------------------
3638// Copyright 2020 Bloomberg Finance L.P.
3639//
3640// Licensed under the Apache License, Version 2.0 (the "License");
3641// you may not use this file except in compliance with the License.
3642// You may obtain a copy of the License at
3643//
3644// http://www.apache.org/licenses/LICENSE-2.0
3645//
3646// Unless required by applicable law or agreed to in writing, software
3647// distributed under the License is distributed on an "AS IS" BASIS,
3648// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3649// See the License for the specific language governing permissions and
3650// limitations under the License.
3651// ----------------------------- END-OF-FILE ----------------------------------
3652
3653/** @} */
3654/** @} */
3655/** @} */
#define BSLMF_NESTED_TRAIT_DECLARATION(t_TYPE, t_TRAIT)
Definition bslmf_nestedtraitdeclaration.h:231
Definition bslstl_function.h:737
Forward declaration.
Definition bslstl_function.h:946
Function_Rep::allocator_type allocator_type
Definition bslstl_function.h:1020
Definition bslmf_referencewrapper.h:182
Imp::Type Type
Definition bslmf_forwardingtype.h:441
Definition bslstl_function_rep.h:132
Definition bslstl_function.h:812
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2343
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2349
#define BSLS_DEPRECATE_FEATURE(UOR, FEATURE, MESSAGE)
Definition bsls_deprecatefeature.h:387
#define BSLS_KEYWORD_DELETED
Definition bsls_keyword.h:651
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:674
BloombergLP::bslma::Allocator * allocator() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function.h:1863
function & operator=(const function &rhs)
Definition bslstl_function.h:1760
allocator_type get_allocator() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function.h:1819
const std::type_info & target_type() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function.h:1834
bool isInplace() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function.h:1870
void swap(function &other) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function.h:1790
TP * target() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function.h:1798
function() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_function.h:1693
bool operator!=(const FileCleanerConfiguration &lhs, const FileCleanerConfiguration &rhs)
bool operator==(const FileCleanerConfiguration &lhs, const FileCleanerConfiguration &rhs)
void swap(OptionValue &a, OptionValue &b)
Definition bdlat_valuetypefunctions.h:939
BloombergLP::bsls::Nullptr_Impl::Type nullptr_t
Definition bsls_nullptr.h:283
void swap(array< VALUE_TYPE, SIZE > &lhs, array< VALUE_TYPE, SIZE > &rhs)
bool operator==(const memory_resource &a, const memory_resource &b)
bool operator!=(const memory_resource &a, const memory_resource &b)
Definition bslstl_algorithm.h:84
Definition bdldfp_decimal.h:5549
Definition bslmf_integralconstant.h:261
Definition bslmf_isnothrowmoveconstructible.h:361
static bool isNull(const FUNC &)
Return false.
Definition bslstl_function_invokerutil.h:831
static BSLA_NORETURN void throwBadFunctionCall()