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