BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bdlf_memfn.h
Go to the documentation of this file.
1/// @file bdlf_memfn.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bdlf_memfn.h -*-C++-*-
8#ifndef INCLUDED_BDLF_MEMFN
9#define INCLUDED_BDLF_MEMFN
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bdlf_memfn bdlf_memfn
15/// @brief Provide member function pointer wrapper classes and utility.
16/// @addtogroup bdl
17/// @{
18/// @addtogroup bdlf
19/// @{
20/// @addtogroup bdlf_memfn
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bdlf_memfn-purpose"> Purpose</a>
25/// * <a href="#bdlf_memfn-classes"> Classes </a>
26/// * <a href="#bdlf_memfn-description"> Description </a>
27/// * <a href="#bdlf_memfn-usage"> Usage </a>
28/// * <a href="#bdlf_memfn-example-1-basic-usage"> Example 1: Basic Usage </a>
29/// * <a href="#bdlf_memfn-example-2-usage-with-standard-algorithms"> Example 2: Usage with Standard Algorithms </a>
30///
31/// # Purpose {#bdlf_memfn-purpose}
32/// Provide member function pointer wrapper classes and utility.
33///
34/// # Classes {#bdlf_memfn-classes}
35///
36/// - bdlf::MemFn: member function wrapper
37/// - bdlf::MemFnInstance: member function wrapper with embedded instance pointer
38/// - bdlf::MemFnUtil: utility for constructing wrapper objects
39///
40/// @see bdlf_bind
41///
42/// # Description {#bdlf_memfn-description}
43/// This component provides a member function pointer wrapper that
44/// wraps a member function pointer such that it can be invoked in syntactically
45/// the same manner as a free function. Two wrappers, each supporting member
46/// function pointers that accept from zero to fourteen arguments, are provided,
47/// as well as a utility to create such wrappers. Member function wrappers are
48/// commonly used as function objects for standard algorithms.
49///
50/// The first wrapper, `bdlf::MemFn`, contains a member function pointer and
51/// must be invoked with the first argument being a pointer or reference to the
52/// instance on which the function should be invoked, with the remaining
53/// arguments passed as arguments to the member function; that is, a wrapper
54/// `memFn` containing a pointer to a given `memberFunction` can be invoked as
55/// `memFn(&object, args...)` as opposed to `object.memberFunction(args...)`.
56///
57/// The second wrapper, `bdlf::MemFnInstance`, contains both the member function
58/// pointer and a pointer to an instance of the type which contains the member,
59/// and is invoked with arguments which are passed as arguments to the member
60/// function; that is, a wrapper `memFnInstance` containing pointers to both a
61/// given `memberFunction` and to an `object` instance can be invoked as
62/// `memFnInstance(args...)` as opposed to `object.memberFunction(args...)`.
63///
64/// Finally, the `bdlf::MemFnUtil` utility class provides utility functions for
65/// constructing `bdlf::MemFn` and `bdlf::MemFnInstance` objects.
66///
67/// ## Usage {#bdlf_memfn-usage}
68///
69///
70/// This section illustrates intended use of this component.
71///
72/// ### Example 1: Basic Usage {#bdlf_memfn-example-1-basic-usage}
73///
74///
75/// To illustrate basic usage more concretely, let us introduce a generic type:
76/// @code
77/// class MyObject {
78/// public:
79/// void doSomething(int, const char *);
80/// };
81/// @endcode
82/// The following function invokes the member function `doSomething` on the
83/// specified `objectPtr`, with the two arguments 100 and "Hello", in two
84/// different ways. In both cases, `object` is passed as parameter to a
85/// function, and a wrapper is built containing a pointer to the `doSomething`
86/// member function. In the `bdlf::MemFn` case, the wrapper can be built once,
87/// so we make it a `static` local variable:
88/// @code
89/// void doSomethingWithMemFn(MyObject *objectPtr)
90/// {
91/// typedef bdlf::MemFn<void (MyObject::*)(int, const char *)> MemFnType;
92/// static MemFnType func(&MyObject::doSomething);
93///
94/// func(objectPtr, 100, "Hello");
95/// }
96/// @endcode
97/// In the `bdlf::MemFnInstance` case, the wrapper needs to contain the object
98/// as well, so it must be created at every function call:
99/// @code
100/// void doSomethingWithMemFnInstance(MyObject *objectPtr)
101/// {
102/// typedef bdlf::MemFnInstance<void (MyObject::*)(int, const char*),
103/// MyObject*> MemFnInstanceType;
104/// MemFnInstanceType func(&MyObject::doSomething, objectPtr);
105/// func(100, "Hello");
106/// }
107/// @endcode
108/// This latter example is for exposition only. It would be much easier to
109/// invoke the member function directly. Note that both function calls
110/// ultimately result in the member function call:
111/// @code
112/// objectPtr->doSomething(100, "Hello");
113/// @endcode
114///
115/// ### Example 2: Usage with Standard Algorithms {#bdlf_memfn-example-2-usage-with-standard-algorithms}
116///
117///
118/// The following example demonstrates the use of `bdlf::MemFn` with the
119/// standard algorithms `find_if` and @ref for_each . First we declare the
120/// `MyConnection` and `MyConnectionManager` classes used in the example,
121/// keeping the class definitions short to highlight the member functions for
122/// which we will later build wrappers:
123/// @code
124/// class MyConnection {
125///
126/// // DATA (not shown)
127///
128/// public:
129/// // CREATORS (not shown)
130///
131/// // MANIPULATORS
132/// void disconnect();
133///
134/// // ACCESSORS
135/// bool isAvailable() const;
136/// };
137///
138/// class MyConnectionManager {
139///
140/// // PRIVATE TYPES
141/// typedef bsl::list<MyConnection *> MyConnectionList;
142///
143/// // DATA
144/// MyConnectionList d_list;
145///
146/// public:
147/// // CREATORS (not shown)
148///
149/// // MANIPULATORS
150/// void disconnectAll();
151///
152/// // ACCESSORS
153/// MyConnection *nextAvailable() const;
154/// };
155/// @endcode
156/// The `nextAvailable` function returns the next `MyConnection` object that is
157/// available. The `find_if` algorithm is used to search the list for the first
158/// `MyConnection` object that is available. `find_if` invokes the provided
159/// function object for each item in the list until a `true` result is returned,
160/// or the end of the list is reached. A `bdlf::MemFn` object bound to the
161/// `MyConnection::isAvailable` member function is used as the test functor.
162/// Note that the type of this object is never spelled out, it is built on the
163/// fly using the `bdlf::MemFnUtil` utility before being passed as a functor to
164/// the `bsl::find_if` algorithm:
165/// @code
166/// MyConnection *MyConnectionManager::nextAvailable() const
167/// {
168/// MyConnectionList::const_iterator it =
169/// bsl::find_if(d_list.begin(),
170/// d_list.end(),
171/// bdlf::MemFnUtil::memFn(&MyConnection::isAvailable));
172/// return it == d_list.end() ? 0 : *it;
173/// }
174/// @endcode
175/// The `disconnectAll` function calls `disconnect` on each `MyConnection`
176/// object in the list. The @ref for_each algorithm is used to iterate through
177/// each `MyConnection` object in the list and invoke the `disconnect` method:
178/// @code
179/// void MyConnectionManager::disconnectAll()
180/// {
181/// bsl::for_each(d_list.begin(),
182/// d_list.end(),
183/// bdlf::MemFnUtil::memFn(&MyConnection::disconnect));
184/// }
185/// @endcode
186/// @}
187/** @} */
188/** @} */
189
190/** @addtogroup bdl
191 * @{
192 */
193/** @addtogroup bdlf
194 * @{
195 */
196/** @addtogroup bdlf_memfn
197 * @{
198 */
199
200#include <bdlscm_version.h>
201
203
204#include <bslma_default.h>
206
207#include <bslmf_assert.h>
208#include <bslmf_forwardingtype.h>
211#include <bslmf_ispointer.h>
213#include <bslmf_typelist.h>
214
215#include <bslma_allocator.h>
216
217#include <bsls_platform.h>
218
219
220
221
222
223namespace bdlf {
224 // =======================
225 // class MemFn_Dereference
226 // =======================
227
228/// This utility is used to convert user supplied values to references to
229/// `OBJTYPE` for object references that are directly convertible to
230/// `OBJTYPE`, the reference is returned directly. For pointers and objects
231/// that are not directly convertible (e.g., "smart pointers to `OBJTYPE`"),
232/// the result of `*OBJECT` is returned, where `OBJECT` is the pointer or
233/// object reference.
234///
235/// See @ref bdlf_memfn
236template <class OBJTYPE>
238
239 static inline OBJTYPE& derefImp(OBJTYPE& obj, bsl::false_type *)
240 {
241 return obj;
242 }
243
244 template <class TYPE>
245 static inline OBJTYPE& derefImp(TYPE& obj, bsl::true_type *)
246 {
247 return *obj;
248 }
249
250 template <class TYPE>
251 static inline OBJTYPE& derefImp(const TYPE& obj, bsl::true_type *)
252 {
253 return *obj;
254 }
255
256 template <class TYPE>
257 static inline OBJTYPE& deref(TYPE& obj)
258 {
260 }
261
262 template <class TYPE>
263 static inline OBJTYPE& deref(const TYPE& obj)
264 {
266 }
267};
268
269 // ===========
270 // class MemFn
271 // ===========
272
273/// This class encapsulates a member function pointer having the
274/// parameterized `PROTOTYPE`, such that the member function pointer can be
275/// invoked in syntactically the same manner as a free function pointer.
276/// When invoking a member function through this wrapper, the first argument
277/// must be a pointer or reference to the instance on which to invoke the
278/// member function pointer. Zero to fourteen additional arguments may be
279/// specified depending on `PROTOTYPE`.
280///
281/// See @ref bdlf_memfn
282template <class PROTOTYPE>
283class MemFn {
284
285 // PRIVATE TYPES
287
288 // ASSERTIONS
289 BSLMF_ASSERT(Traits::IS_MEMBER_FUNCTION_PTR); // otherwise none of the
290 // 'typedef's below make any
291 // sense
292
293 public:
294 // TYPES
295
296 /// `ResultType` is an alias for the type of the object returned by an
297 /// invocation of this member function wrapper.
298 typedef typename Traits::ResultType ResultType;
299
300 /// `Args` is an alias for the list of arguments passed to an invocation
301 /// of this member function wrapper, expressed as a `bslmf_Typelist`.
302 typedef typename Traits::ArgumentList Args;
303
304 /// `ObjectType` is an alias for the class type to which the member
305 /// function that is wrapped belongs.
306 typedef typename Traits::ClassType ObjectType;
307
308 /// `ProtoType` is an alias for the parameterized `PROTOTYPE` passed as
309 /// a template argument to this wrapper.
310 typedef PROTOTYPE Prototype;
311
312 /// `ProtoType` is an alias for the parameterized `PROTOTYPE` passed as
313 /// a template argument to this wrapper.
314 ///
315 /// *DEPRECATED*: Use `Prototype` instead.
316 typedef PROTOTYPE ProtoType;
317
318 private:
319 // PRIVATE TYPES
320 typedef typename bslmf::ForwardingType<
322 typedef typename bslmf::ForwardingType<
324 typedef typename bslmf::ForwardingType<
326 typedef typename bslmf::ForwardingType<
328 typedef typename bslmf::ForwardingType<
330 typedef typename bslmf::ForwardingType<
332 typedef typename bslmf::ForwardingType<
334 typedef typename bslmf::ForwardingType<
336 typedef typename bslmf::ForwardingType<
338 typedef typename bslmf::ForwardingType<
340 typedef typename bslmf::ForwardingType<
342 typedef typename bslmf::ForwardingType<
344 typedef typename bslmf::ForwardingType<
346
347 /// `AN`, for `N` from 1 up to 14, is an alias for the type of the `N`th
348 /// argument in the `Args` list.
349 typedef typename bslmf::ForwardingType<
351
352 typedef MemFn_Dereference<ObjectType> Deref;
353
354 // DATA
355 PROTOTYPE d_func_p; // pointer to member function
356
357 public:
358 // CREATORS
359
360 /// Create a member function pointer wrapper holding the address of the
361 /// specified `func` member function having the parameterized
362 /// `PROTOTYPE`.
363 explicit
364 MemFn(PROTOTYPE func);
365
366 /// Create a member function pointer wrapper holding the address of the
367 /// same member function as the specified `original` object.
368 MemFn(const MemFn<PROTOTYPE>& original);
369
370 /// Destroy this object.
371 ~MemFn() = default;
372
373 // ACCESSORS
374
375#if defined(BSLS_PLATFORM_CMP_GNU) && \
376 BSLS_PLATFORM_CMP_VERSION >= 110000 && \
377 BSLS_PLATFORM_CMP_VERSION < 150000
378 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111750
379# pragma GCC diagnostic push
380# pragma GCC diagnostic ignored "-Warray-bounds"
381#endif
382 /// Invoke the member function pointer held by this wrapper on the
383 /// specified `object` reference to a modifiable instance of the
384 /// parameterized `INSTANCE` type, with no specified arguments, and
385 /// return the result of this invocation, or `void` if this member
386 /// function pointer does not return a result.
387 template <class INSTANCE>
388 ResultType operator()(INSTANCE& object) const
389 {
390 return (Deref::deref(object).*d_func_p)();
391 }
392
393 /// Invoke the member function pointer held by this wrapper on the
394 /// specified `object` reference to a modifiable instance of the
395 /// parameterized `INSTANCE` type, with the specified argument `arg1`,
396 /// and return the result of this invocation, or `void` if this member
397 /// function pointer does not return a result.
398 template <class INSTANCE>
399 ResultType operator()(INSTANCE& object, ARG1 arg1) const
400 {
401 return (Deref::deref(object).*d_func_p)(arg1); // see NOTES above
402 }
403
404 /// Invoke the member function pointer held by this wrapper on the
405 /// specified `object` reference to a modifiable instance of the
406 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
407 /// to `arg2`, and return the result of this invocation, or `void` if
408 /// this member function pointer does not return a result.
409 template <class INSTANCE>
410 ResultType operator()(INSTANCE& object, ARG1 arg1, ARG2 arg2) const
411 {
412 return (Deref::deref(object).*d_func_p)(arg1, arg2); // etc.
413 }
414
415 /// Invoke the member function pointer held by this wrapper on the
416 /// specified `object` reference to a modifiable instance of the
417 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
418 /// to `arg3`, and return the result of this invocation, or `void` if
419 /// this member function pointer does not return a result.
420 template <class INSTANCE>
421 ResultType operator()(INSTANCE& object,
422 ARG1 arg1, ARG2 arg2, ARG3 arg3) const
423 {
424 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3);
425 }
426
427 /// Invoke the member function pointer held by this wrapper on the
428 /// specified `object` reference to a modifiable instance of the
429 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
430 /// to `arg4`, and return the result of this invocation, or `void` if
431 /// this member function pointer does not return a result.
432 template <class INSTANCE>
433 ResultType operator()(INSTANCE& object,
434 ARG1 arg1, ARG2 arg2, ARG3 arg3,
435 ARG4 arg4) const
436 {
437 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4);
438 }
439
440 /// Invoke the member function pointer held by this wrapper on the
441 /// specified `object` reference to a modifiable instance of the
442 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
443 /// to `arg5`, and return the result of this invocation, or `void` if
444 /// this member function pointer does not return a result.
445 template <class INSTANCE>
446 ResultType operator()(INSTANCE& object,
447 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
448 ARG5 arg5) const
449 {
450 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5);
451 }
452
453 /// Invoke the member function pointer held by this wrapper on the
454 /// specified `object` reference to a modifiable instance of the
455 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
456 /// to `arg6`, and return the result of this invocation, or `void` if
457 /// this member function pointer does not return a result.
458 template <class INSTANCE>
459 ResultType operator()(INSTANCE& object,
460 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
461 ARG5 arg5, ARG6 arg6) const
462 {
463 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
464 arg6);
465 }
466
467 /// Invoke the member function pointer held by this wrapper on the
468 /// specified `object` reference to a modifiable instance of the
469 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
470 /// to `arg7`, and return the result of this invocation, or `void` if
471 /// this member function pointer does not return a result.
472 template <class INSTANCE>
473 ResultType operator()(INSTANCE& object,
474 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
475 ARG5 arg5, ARG6 arg6, ARG7 arg7) const
476 {
477 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
478 arg6, arg7);
479 }
480
481 /// Invoke the member function pointer held by this wrapper on the
482 /// specified `object` reference to a modifiable instance of the
483 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
484 /// to `arg8`, and return the result of this invocation, or `void` if
485 /// this member function pointer does not return a result.
486 template <class INSTANCE>
487 ResultType operator()(INSTANCE& object,
488 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
489 ARG5 arg5, ARG6 arg6, ARG7 arg7,
490 ARG8 arg8) const
491 {
492 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
493 arg6, arg7, arg8);
494 }
495
496 /// Invoke the member function pointer held by this wrapper on the
497 /// specified `object` reference to a modifiable instance of the
498 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
499 /// to `arg9`, and return the result of this invocation, or `void` if
500 /// this member function pointer does not return a result.
501 template <class INSTANCE>
502 ResultType operator()(INSTANCE& object,
503 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
504 ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8,
505 ARG9 arg9) const
506 {
507 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
508 arg6, arg7, arg8, arg9);
509 }
510
511 /// Invoke the member function pointer held by this wrapper on the
512 /// specified `object` reference to a modifiable instance of the
513 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
514 /// to `arg10`, and return the result of this invocation, or `void` if
515 /// this member function pointer does not return a result.
516 template <class INSTANCE>
517 ResultType operator()(INSTANCE& object,
518 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
519 ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8,
520 ARG9 arg9, ARG10 arg10) const
521 {
522 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
523 arg6, arg7, arg8, arg9, arg10);
524 }
525
526 /// Invoke the member function pointer held by this wrapper on the
527 /// specified `object` reference to a modifiable instance of the
528 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
529 /// to `arg11`, and return the result of this invocation, or `void` if
530 /// this member function pointer does not return a result.
531 template <class INSTANCE>
532 ResultType operator()(INSTANCE& object,
533 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
534 ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8,
535 ARG9 arg9, ARG10 arg10, ARG11 arg11) const
536 {
537 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
538 arg6, arg7, arg8, arg9, arg10,
539 arg11);
540 }
541
542 /// Invoke the member function pointer held by this wrapper on the
543 /// specified `object` reference to a modifiable instance of the
544 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
545 /// to `arg12`, and return the result of this invocation, or `void` if
546 /// this member function pointer does not return a result.
547 template <class INSTANCE>
548 ResultType operator()(INSTANCE& object,
549 ARG1 arg1, ARG2 arg2, ARG3 arg3,
550 ARG4 arg4, ARG5 arg5, ARG6 arg6,
551 ARG7 arg7, ARG8 arg8, ARG9 arg9,
552 ARG10 arg10, ARG11 arg11, ARG12 arg12) const
553 {
554 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
555 arg6, arg7, arg8, arg9, arg10,
556 arg11, arg12);
557 }
558
559 /// Invoke the member function pointer held by this wrapper on the
560 /// specified `object` reference to a modifiable instance of the
561 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
562 /// to `arg13`, and return the result of this invocation, or `void` if
563 /// this member function pointer does not return a result.
564 template <class INSTANCE>
565 ResultType operator()(INSTANCE& object,
566 ARG1 arg1, ARG2 arg2, ARG3 arg3,
567 ARG4 arg4, ARG5 arg5, ARG6 arg6,
568 ARG7 arg7, ARG8 arg8, ARG9 arg9,
569 ARG10 arg10, ARG11 arg11, ARG12 arg12,
570 ARG13 arg13) const
571 {
572 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
573 arg6, arg7, arg8, arg9, arg10,
574 arg11, arg12, arg13);
575 }
576
577 /// Invoke the member function pointer held by this wrapper on the
578 /// specified `object` reference to a modifiable instance of the
579 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
580 /// to `arg14`, and return the result of this invocation, or `void` if
581 /// this member function pointer does not return a result.
582 template <class INSTANCE>
583 ResultType operator()(INSTANCE& object,
584 ARG1 arg1, ARG2 arg2, ARG3 arg3,
585 ARG4 arg4, ARG5 arg5, ARG6 arg6,
586 ARG7 arg7, ARG8 arg8, ARG9 arg9,
587 ARG10 arg10, ARG11 arg11, ARG12 arg12,
588 ARG13 arg13, ARG14 arg14) const
589 {
590 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
591 arg6, arg7, arg8, arg9, arg10,
592 arg11, arg12, arg13, arg14);
593 }
594
595 /// Invoke the member function pointer held by this wrapper on the
596 /// specified `object` reference to a non-modifiable instance of the
597 /// parameterized `INSTANCE` type, with no arguments, and return the
598 /// result of this invocation, or `void` if this member function pointer
599 /// does not return a result.
600 template <class INSTANCE>
601 ResultType operator()(const INSTANCE& object) const
602 {
603 return (Deref::deref(object).*d_func_p)();
604 }
605
606 /// Invoke the member function pointer held by this wrapper on the
607 /// specified `object` reference to a non-modifiable instance of the
608 /// parameterized `INSTANCE` type, with the specified argument `arg1`,
609 /// and return the result of this invocation, or `void` if this member
610 /// function pointer does not return a result.
611 template <class INSTANCE>
612 ResultType operator()(const INSTANCE& object, ARG1 arg1) const
613 {
614 return (Deref::deref(object).*d_func_p)(arg1);
615 }
616
617 /// Invoke the member function pointer held by this wrapper on the
618 /// specified `object` reference to a non-modifiable instance of the
619 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
620 /// up to `arg2`, and return the result of this invocation, or `void` if
621 /// this member function pointer does not return a result.
622 template <class INSTANCE>
623 ResultType operator()(const INSTANCE& object, ARG1 arg1, ARG2 arg2) const
624 {
625 return (Deref::deref(object).*d_func_p)(arg1, arg2);
626 }
627
628 /// Invoke the member function pointer held by this wrapper on the
629 /// specified `object` reference to a non-modifiable instance of the
630 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
631 /// up to `arg3`, and return the result of this invocation, or `void` if
632 /// this member function pointer does not return a result.
633 template <class INSTANCE>
634 ResultType operator()(const INSTANCE& object,
635 ARG1 arg1, ARG2 arg2, ARG3 arg3) const
636 {
637 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3);
638 }
639
640 /// Invoke the member function pointer held by this wrapper on the
641 /// specified `object` reference to a non-modifiable instance of the
642 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
643 /// up to `arg4`, and return the result of this invocation, or `void` if
644 /// this member function pointer does not return a result.
645 template <class INSTANCE>
646 ResultType operator()(const INSTANCE& object,
647 ARG1 arg1, ARG2 arg2, ARG3 arg3,
648 ARG4 arg4) const
649 {
650 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4);
651 }
652
653 /// Invoke the member function pointer held by this wrapper on the
654 /// specified `object` reference to a non-modifiable instance of the
655 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
656 /// up to `arg5`, and return the result of this invocation, or `void` if
657 /// this member function pointer does not return a result.
658 template <class INSTANCE>
659 ResultType operator()(const INSTANCE& object,
660 ARG1 arg1, ARG2 arg2, ARG3 arg3,
661 ARG4 arg4, ARG5 arg5) const
662 {
663 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5);
664 }
665
666 /// Invoke the member function pointer held by this wrapper on the
667 /// specified `object` reference to a non-modifiable instance of the
668 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
669 /// up to `arg6`, and return the result of this invocation, or `void` if
670 /// this member function pointer does not return a result.
671 template <class INSTANCE>
672 ResultType operator()(const INSTANCE& object,
673 ARG1 arg1, ARG2 arg2, ARG3 arg3,
674 ARG4 arg4, ARG5 arg5, ARG6 arg6) const
675 {
676 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
677 arg6);
678 }
679
680 /// Invoke the member function pointer held by this wrapper on the
681 /// specified `object` reference to a non-modifiable instance of the
682 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
683 /// up to `arg7`, and return the result of this invocation, or `void` if
684 /// this member function pointer does not return a result.
685 template <class INSTANCE>
686 ResultType operator()(const INSTANCE& object,
687 ARG1 arg1, ARG2 arg2, ARG3 arg3,
688 ARG4 arg4, ARG5 arg5, ARG6 arg6,
689 ARG7 arg7) const
690 {
691 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
692 arg6, arg7);
693 }
694
695 /// Invoke the member function pointer held by this wrapper on the
696 /// specified `object` reference to a non-modifiable instance of the
697 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
698 /// up to `arg8`, and return the result of this invocation, or `void` if
699 /// this member function pointer does not return a result.
700 template <class INSTANCE>
701 ResultType operator()(const INSTANCE& object,
702 ARG1 arg1, ARG2 arg2, ARG3 arg3,
703 ARG4 arg4, ARG5 arg5, ARG6 arg6,
704 ARG7 arg7, ARG8 arg8) const
705 {
706 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
707 arg6, arg7, arg8);
708 }
709
710 /// Invoke the member function pointer held by this wrapper on the
711 /// specified `object` reference to a non-modifiable instance of the
712 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
713 /// up to `arg9`, and return the result of this invocation, or `void` if
714 /// this member function pointer does not return a result.
715 template <class INSTANCE>
716 ResultType operator()(const INSTANCE& object,
717 ARG1 arg1, ARG2 arg2, ARG3 arg3,
718 ARG4 arg4, ARG5 arg5, ARG6 arg6,
719 ARG7 arg7, ARG8 arg8, ARG9 arg9) const
720 {
721 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
722 arg6, arg7, arg8, arg9);
723 }
724
725 /// Invoke the member function pointer held by this wrapper on the
726 /// specified `object` reference to a non-modifiable instance of the
727 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
728 /// up to `arg10`, and return the result of this invocation, or `void`
729 /// if this member function pointer does not return a result.
730 template <class INSTANCE>
731 ResultType operator()(const INSTANCE& object,
732 ARG1 arg1, ARG2 arg2, ARG3 arg3,
733 ARG4 arg4, ARG5 arg5, ARG6 arg6,
734 ARG7 arg7, ARG8 arg8, ARG9 arg9,
735 ARG10 arg10) const
736 {
737 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
738 arg6, arg7, arg8, arg9, arg10);
739 }
740
741 /// Invoke the member function pointer held by this wrapper on the
742 /// specified `object` reference to a non-modifiable instance of the
743 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
744 /// up to `arg11`, and return the result of this invocation, or `void`
745 /// if this member function pointer does not return a result.
746 template <class INSTANCE>
747 ResultType operator()(const INSTANCE& object,
748 ARG1 arg1, ARG2 arg2, ARG3 arg3,
749 ARG4 arg4, ARG5 arg5, ARG6 arg6,
750 ARG7 arg7, ARG8 arg8, ARG9 arg9,
751 ARG10 arg10, ARG11 arg11) const
752 {
753 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
754 arg6, arg7, arg8, arg9, arg10,
755 arg11);
756 }
757
758 /// Invoke the member function pointer held by this wrapper on the
759 /// specified `object` reference to a non-modifiable instance of the
760 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
761 /// up to `arg12`, and return the result of this invocation, or `void`
762 /// if this member function pointer does not return a result.
763 template <class INSTANCE>
764 ResultType operator()(const INSTANCE& object,
765 ARG1 arg1, ARG2 arg2, ARG3 arg3,
766 ARG4 arg4, ARG5 arg5, ARG6 arg6,
767 ARG7 arg7, ARG8 arg8, ARG9 arg9,
768 ARG10 arg10, ARG11 arg11,
769 ARG12 arg12) const
770 {
771 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
772 arg6, arg7, arg8, arg9, arg10,
773 arg11, arg12);
774 }
775
776 /// Invoke the member function pointer held by this wrapper on the
777 /// specified `object` reference to a non-modifiable instance of the
778 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
779 /// up to `arg13`, and return the result of this invocation, or `void`
780 /// if this member function pointer does not return a result.
781 template <class INSTANCE>
782 ResultType operator()(const INSTANCE& object,
783 ARG1 arg1, ARG2 arg2, ARG3 arg3,
784 ARG4 arg4, ARG5 arg5, ARG6 arg6,
785 ARG7 arg7, ARG8 arg8, ARG9 arg9,
786 ARG10 arg10, ARG11 arg11, ARG12 arg12,
787 ARG13 arg13) const
788 {
789 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4,
790 arg5, arg6, arg7, arg8,
791 arg9, arg10, arg11, arg12,
792 arg13);
793 }
794
795 /// Invoke the member function pointer held by this wrapper on the
796 /// specified `object` reference to a non-modifiable instance of the
797 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
798 /// up to `arg14`, and return the result of this invocation, or `void`
799 /// if this member function pointer does not return a result.
800 template <class INSTANCE>
801 ResultType operator()(const INSTANCE& object,
802 ARG1 arg1, ARG2 arg2, ARG3 arg3,
803 ARG4 arg4, ARG5 arg5, ARG6 arg6,
804 ARG7 arg7, ARG8 arg8, ARG9 arg9,
805 ARG10 arg10, ARG11 arg11, ARG12 arg12,
806 ARG13 arg13, ARG14 arg14) const
807 {
808 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
809 arg6, arg7, arg8, arg9, arg10,
810 arg11, arg12, arg13, arg14);
811 }
812#if defined(BSLS_PLATFORM_CMP_GNU) && \
813 BSLS_PLATFORM_CMP_VERSION >= 110000 && \
814 BSLS_PLATFORM_CMP_VERSION < 150000
815# pragma GCC diagnostic pop
816#endif
817};
818
819 // ===================
820 // class MemFnInstance
821 // ===================
822
823/// This class encapsulates a member function pointer having the
824/// parameterized `PROTOTYPE` and a value of the parameterized `INSTANCE`
825/// type, which can be either be the type of object referred to by the
826/// `PROTOTYPE`, or a pointer to one, such that the member function pointer
827/// can be invoked on the wrapped instance in syntactically the same manner
828/// as a free function pointer. Zero to fourteen additional arguments may be specified depending on the `PROTOTYPE`.
829///
830/// \note Note that whether `INSTANCE`
831/// is a pointer or an object is determined by whether it has pointer
832/// semantics or not (as determined by the `bslmf::HasPointerSemantics` type
833/// trait). Also note that if `INSTANCE` is an object that does not have
834/// pointer semantics, `PROTOTYPE` must be const-qualified.
835///
836/// See @ref bdlf_memfn
837template <class PROTOTYPE, class INSTANCE>
839
840 // PRIVATE TYPES
842
843 public:
844 // TYPES
845
846 /// `ResultType` is an alias for the type of the object returned by an
847 /// invocation of this member function wrapper.
848 typedef typename Traits::ResultType ResultType;
849
850 /// `Args` is an alias for the list of arguments passed to an invocation
851 /// of this member function wrapper, expressed as a `bslmf_Typelist`.
852 typedef typename Traits::ArgumentList Args;
853
854 /// `ObjectType` is an alias for the class type to which the member
855 /// function that is wrapped belongs.
856 typedef typename Traits::ClassType ObjectType;
857
858 /// `ProtoType` is an alias for the parameterized `PROTOTYPE` passed as
859 /// a template argument to this wrapper.
860 typedef PROTOTYPE Prototype;
861
862 /// `ProtoType` is an alias for the parameterized `PROTOTYPE` passed as
863 /// a template argument to this wrapper.
864 ///
865 /// @deprecated Use @ref Prototype instead.
866 typedef PROTOTYPE ProtoType;
867
869
870
871 private:
872 // PRIVATE TYPES
873 typedef typename bslmf::ForwardingType<
875 typedef typename bslmf::ForwardingType<
877 typedef typename bslmf::ForwardingType<
879 typedef typename bslmf::ForwardingType<
881 typedef typename bslmf::ForwardingType<
883 typedef typename bslmf::ForwardingType<
885 typedef typename bslmf::ForwardingType<
887 typedef typename bslmf::ForwardingType<
889 typedef typename bslmf::ForwardingType<
891 typedef typename bslmf::ForwardingType<
893 typedef typename bslmf::ForwardingType<
895 typedef typename bslmf::ForwardingType<
897 typedef typename bslmf::ForwardingType<
899
900 /// `AN`, for `N` from 1 up to 14, is an alias for the type of the `N`th
901 /// argument in the `Args` list.
902 typedef typename bslmf::ForwardingType<
904
905 // DATA
906 PROTOTYPE d_func_p; // pointer to member function
907
908 bslalg::ConstructorProxy<INSTANCE> d_obj; // object instance, or
909 // pointer to such
910
911 // PRIVATE ACCESSORS
912 public:
913 // CREATORS
914
915 /// Create a member function pointer wrapper around the specified `func`
916 /// member function pointer of the parameterized `PROTOTYPE`, that is
917 /// invocable on the specified `object` instance of the parameterized
918 /// `INSTANCE`. Optionally specify a `basicAllocator` used to supply
919 /// memory. If `basicAllocator` is 0, the currently installed default
920 /// allocator is used.
921 MemFnInstance(PROTOTYPE func,
922 const INSTANCE& object,
923 bslma::Allocator *basicAllocator = 0);
924
925 /// Create a member function pointer wrapper around the same member
926 /// function and instance pointed to by the specified `original` object.
927 /// Optionally specify a `basicAllocator` used to supply memory. If
928 /// `basicAllocator` is 0, the currently installed default allocator is
929 /// used.
930 MemFnInstance(const MemFnInstance& original,
931 bslma::Allocator *basicAllocator = 0);
932
933 /// Destroy this object.
935
936 // MANIPULATORS
937
938 /// Assign to this member function pointer wrapper the same member
939 /// function and instance pointed to by the specified `rhs` member
940 /// function pointer wrapper, and return a reference to this modifiable
941 /// member function pointer wrapper.
943
944 // ACCESSORS
945
946 /// Invoke the member function pointer held by this wrapper on the
947 /// provided object with the specified `arg1` up to `argN` as arguments,
948 /// with `N` being the number of arguments of the member function, and
949 /// return the result of this invocation, or `void` if this member
950 /// function pointer does not return a result.
951 ResultType operator()() const;
952 ResultType operator()(ARG1 arg1) const;
953 ResultType operator()(ARG1 arg1, ARG2 arg2) const;
954 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3) const;
955 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4) const;
956 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
957 ARG5 arg5) const;
958 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
959 ARG5 arg5, ARG6 arg6) const;
960 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
961 ARG5 arg5, ARG6 arg6,
962 ARG7 arg7) const;
963 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
964 ARG5 arg5, ARG6 arg6,
965 ARG7 arg7, ARG8 arg8) const;
966 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
967 ARG5 arg5, ARG6 arg6,
968 ARG7 arg7, ARG8 arg8, ARG9 arg9) const;
969 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
970 ARG5 arg5, ARG6 arg6,
971 ARG7 arg7, ARG8 arg8, ARG9 arg9, ARG10 arg10) const;
972 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
973 ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8,
974 ARG9 arg9, ARG10 arg10, ARG11 arg11) const;
975 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
976 ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8,
977 ARG9 arg9, ARG10 arg10, ARG11 arg11,
978 ARG12 arg12) const;
979 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
980 ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8,
981 ARG9 arg9, ARG10 arg10, ARG11 arg11, ARG12 arg12,
982 ARG13 arg13) const;
983 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
984 ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8,
985 ARG9 arg9, ARG10 arg10, ARG11 arg11, ARG12 arg12,
986 ARG13 arg13, ARG14 arg14) const;
987};
988
989 // ================
990 // struct MemFnUtil
991 // ================
992
993/// The methods provided in this utility are used for constructing `MemFn`
994/// and `MemFnInstance` objects from function pointers.
995///
996/// See @ref bdlf_memfn
997struct MemFnUtil {
998
999 // CLASS METHODS
1000
1001 /// Return a `MemFn` member function wrapper that encapsulates the
1002 /// specified `func` member function pointer of the parameterized
1003 /// `PROTOTYPE`.
1004 template <class PROTOTYPE>
1005 static
1006 MemFn<PROTOTYPE> memFn(PROTOTYPE func);
1007
1008 /// Return a `MemFnInstance` member function wrapper that encapsulates
1009 /// the specified `func` member function pointer of the parameterized
1010 /// `PROTOTYPE` and the specified `object` instance of the parameterized
1011 /// `INSTANCE` type.
1012 template <class PROTOTYPE, class INSTANCE>
1013 static
1015 const INSTANCE& object);
1016};
1017
1018// ============================================================================
1019// INLINE FUNCTION DEFINITIONS
1020// ============================================================================
1021
1022 // -----------
1023 // class MemFn
1024 // -----------
1025
1026// CREATORS
1027template <class PROTOTYPE>
1028inline
1030: d_func_p(func)
1031{
1032}
1033
1034template <class PROTOTYPE>
1035inline
1037: d_func_p(original.d_func_p)
1038{
1039}
1040
1041 // -------------------
1042 // class MemFnInstance
1043 // -------------------
1044
1045// CREATORS
1046template <class PROTOTYPE, class INSTANCE>
1047inline
1049 const MemFnInstance<PROTOTYPE, INSTANCE>& original,
1050 bslma::Allocator *basicAllocator)
1051: d_func_p(original.d_func_p)
1052, d_obj(original.d_obj, bslma::Default::allocator(basicAllocator))
1053{
1054}
1055
1056template <class PROTOTYPE, class INSTANCE>
1057inline
1059 PROTOTYPE func,
1060 const INSTANCE& object,
1061 bslma::Allocator *basicAllocator)
1062: d_func_p(func)
1063, d_obj(object, bslma::Default::allocator(basicAllocator))
1064{
1065}
1066
1067template <class PROTOTYPE, class INSTANCE>
1068inline
1072
1073// MANIPULATORS
1074template <class PROTOTYPE, class INSTANCE>
1075inline
1078 const MemFnInstance& rhs)
1079{
1080 d_func_p = rhs.d_func_p;
1081 d_obj.object() = rhs.d_obj.object();
1082 return *this;
1083}
1084
1085// ACCESSORS
1086template <class PROTOTYPE, class INSTANCE>
1087inline
1090{
1091 return (Deref::deref(d_obj.object()).*d_func_p)();
1092}
1093
1094template <class PROTOTYPE, class INSTANCE>
1095inline
1098{
1099 return (Deref::deref(d_obj.object()).*d_func_p)(arg1);
1100}
1101
1102template <class PROTOTYPE, class INSTANCE>
1103inline
1106{
1107 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2);
1108}
1109
1110template <class PROTOTYPE, class INSTANCE>
1111inline
1114 ARG1 arg1, ARG2 arg2, ARG3 arg3) const
1115{
1116 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3);
1117}
1118
1119template <class PROTOTYPE, class INSTANCE>
1120inline
1123 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4) const
1124{
1125 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3, arg4);
1126}
1127
1128template <class PROTOTYPE, class INSTANCE>
1129inline
1132 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5) const
1133{
1134 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3, arg4,
1135 arg5);
1136}
1137
1138template <class PROTOTYPE, class INSTANCE>
1139inline
1142 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6) const
1143{
1144 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3, arg4,
1145 arg5, arg6);
1146}
1147
1148template <class PROTOTYPE, class INSTANCE>
1149inline
1152 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6,
1153 ARG7 arg7) const
1154{
1155 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3, arg4,
1156 arg5, arg6, arg7);
1157}
1158
1159template <class PROTOTYPE, class INSTANCE>
1160inline
1163 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6,
1164 ARG7 arg7, ARG8 arg8) const
1165{
1166 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3, arg4,
1167 arg5, arg6, arg7, arg8);
1168}
1169
1170template <class PROTOTYPE, class INSTANCE>
1171inline
1174 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6,
1175 ARG7 arg7, ARG8 arg8, ARG9 arg9) const
1176{
1177 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3, arg4,
1178 arg5, arg6, arg7, arg8,
1179 arg9);
1180}
1181
1182template <class PROTOTYPE, class INSTANCE>
1183inline
1186 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6,
1187 ARG7 arg7, ARG8 arg8, ARG9 arg9, ARG10 arg10) const
1188{
1189 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3, arg4,
1190 arg5, arg6, arg7, arg8,
1191 arg9, arg10);
1192}
1193
1194template <class PROTOTYPE, class INSTANCE>
1195inline
1198 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6,
1199 ARG7 arg7, ARG8 arg8, ARG9 arg9, ARG10 arg10, ARG11 arg11) const
1200{
1201 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3, arg4,
1202 arg5, arg6, arg7, arg8,
1203 arg9, arg10, arg11);
1204}
1205
1206template <class PROTOTYPE, class INSTANCE>
1207inline
1210 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6,
1211 ARG7 arg7, ARG8 arg8, ARG9 arg9, ARG10 arg10, ARG11 arg11,
1212 ARG12 arg12) const
1213{
1214 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3, arg4,
1215 arg5, arg6, arg7, arg8,
1216 arg9, arg10, arg11, arg12);
1217}
1218
1219template <class PROTOTYPE, class INSTANCE>
1220inline
1223 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6,
1224 ARG7 arg7, ARG8 arg8, ARG9 arg9, ARG10 arg10, ARG11 arg11,
1225 ARG12 arg12, ARG13 arg13) const
1226{
1227 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3, arg4,
1228 arg5, arg6, arg7, arg8,
1229 arg9, arg10, arg11, arg12,
1230 arg13);
1231}
1232
1233template <class PROTOTYPE, class INSTANCE>
1234inline
1237 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5,
1238 ARG6 arg6, ARG7 arg7, ARG8 arg8, ARG9 arg9, ARG10 arg10,
1239 ARG11 arg11, ARG12 arg12, ARG13 arg13, ARG14 arg14) const
1240{
1241 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3, arg4,
1242 arg5, arg6, arg7, arg8,
1243 arg9, arg10, arg11, arg12,
1244 arg13, arg14);
1245}
1246
1247 // ----------------
1248 // struct MemFnUtil
1249 // ----------------
1250
1251// CLASS METHODS
1252template <class PROTOTYPE>
1253inline
1255MemFnUtil::memFn(PROTOTYPE func)
1256{
1257 return MemFn<PROTOTYPE>(func);
1258}
1259
1260template <class PROTOTYPE, class INSTANCE>
1261inline
1263MemFnUtil::memFn(PROTOTYPE func, const INSTANCE& object)
1264{
1265 return MemFnInstance<PROTOTYPE, INSTANCE>(func, object);
1266}
1267
1268} // close package namespace
1269
1270
1271// ============================================================================
1272// TYPE TRAITS
1273// ============================================================================
1274
1275
1276namespace bslma {
1277
1278template <class PROTOTYPE, class INSTANCE>
1279struct UsesBslmaAllocator<bdlf::MemFnInstance<PROTOTYPE, INSTANCE> > :
1281{};
1282
1283} // close namespace bslma
1284namespace bslmf {
1285
1286template <class PROTOTYPE, class INSTANCE>
1287struct IsBitwiseMoveable<bdlf::MemFnInstance<PROTOTYPE, INSTANCE> > :
1288 IsBitwiseMoveable<INSTANCE>
1289{};
1290
1291/// This bitwise moveable trait is redundant as it is already implied by the
1292/// `bslmf::IsBitwiseCopyable` trait below. We retain this definition,
1293/// however, as it can potentially save a level of template instantiation.
1294template <class PROTOTYPE>
1295struct IsBitwiseMoveable<bdlf::MemFn<PROTOTYPE> > : bsl::true_type
1296{
1297};
1298
1299template <class PROTOTYPE>
1300struct IsBitwiseCopyable<bdlf::MemFn<PROTOTYPE> > : bsl::true_type
1301{};
1302
1303} // close namespace bslmf
1304
1305
1306#endif
1307
1308// ----------------------------------------------------------------------------
1309// Copyright 2015 Bloomberg Finance L.P.
1310//
1311// Licensed under the Apache License, Version 2.0 (the "License");
1312// you may not use this file except in compliance with the License.
1313// You may obtain a copy of the License at
1314//
1315// http://www.apache.org/licenses/LICENSE-2.0
1316//
1317// Unless required by applicable law or agreed to in writing, software
1318// distributed under the License is distributed on an "AS IS" BASIS,
1319// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1320// See the License for the specific language governing permissions and
1321// limitations under the License.
1322// ----------------------------- END-OF-FILE ----------------------------------
1323
1324/** @} */
1325/** @} */
1326/** @} */
Definition bdlf_memfn.h:838
Traits::ClassType ObjectType
Definition bdlf_memfn.h:856
MemFn_Dereference< ObjectType > Deref
Definition bdlf_memfn.h:868
MemFnInstance(PROTOTYPE func, const INSTANCE &object, bslma::Allocator *basicAllocator=0)
Definition bdlf_memfn.h:1058
PROTOTYPE ProtoType
Definition bdlf_memfn.h:866
~MemFnInstance()
Destroy this object.
Definition bdlf_memfn.h:1069
Traits::ArgumentList Args
Definition bdlf_memfn.h:852
MemFnInstance & operator=(const MemFnInstance &rhs)
Definition bdlf_memfn.h:1077
PROTOTYPE Prototype
Definition bdlf_memfn.h:860
ResultType operator()() const
Definition bdlf_memfn.h:1089
Traits::ResultType ResultType
Definition bdlf_memfn.h:848
Definition bdlf_memfn.h:283
ResultType operator()(INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6, ARG7 arg7) const
Definition bdlf_memfn.h:473
ResultType operator()(const INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5) const
Definition bdlf_memfn.h:659
ResultType operator()(const INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8) const
Definition bdlf_memfn.h:701
ResultType operator()(INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8) const
Definition bdlf_memfn.h:487
ResultType operator()(INSTANCE &object, ARG1 arg1, ARG2 arg2) const
Definition bdlf_memfn.h:410
ResultType operator()(const INSTANCE &object, ARG1 arg1) const
Definition bdlf_memfn.h:612
ResultType operator()(const INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3) const
Definition bdlf_memfn.h:634
ResultType operator()(const INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8, ARG9 arg9) const
Definition bdlf_memfn.h:716
ResultType operator()(INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8, ARG9 arg9, ARG10 arg10, ARG11 arg11, ARG12 arg12) const
Definition bdlf_memfn.h:548
PROTOTYPE ProtoType
Definition bdlf_memfn.h:316
ResultType operator()(INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8, ARG9 arg9, ARG10 arg10) const
Definition bdlf_memfn.h:517
ResultType operator()(const INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8, ARG9 arg9, ARG10 arg10, ARG11 arg11, ARG12 arg12) const
Definition bdlf_memfn.h:764
Traits::ResultType ResultType
Definition bdlf_memfn.h:298
ResultType operator()(INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8, ARG9 arg9) const
Definition bdlf_memfn.h:502
~MemFn()=default
Destroy this object.
ResultType operator()(const INSTANCE &object, ARG1 arg1, ARG2 arg2) const
Definition bdlf_memfn.h:623
ResultType operator()(const INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8, ARG9 arg9, ARG10 arg10, ARG11 arg11, ARG12 arg12, ARG13 arg13) const
Definition bdlf_memfn.h:782
ResultType operator()(INSTANCE &object, ARG1 arg1) const
Definition bdlf_memfn.h:399
ResultType operator()(INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5) const
Definition bdlf_memfn.h:446
Traits::ArgumentList Args
Definition bdlf_memfn.h:302
MemFn(PROTOTYPE func)
Definition bdlf_memfn.h:1029
ResultType operator()(const INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8, ARG9 arg9, ARG10 arg10) const
Definition bdlf_memfn.h:731
ResultType operator()(INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8, ARG9 arg9, ARG10 arg10, ARG11 arg11, ARG12 arg12, ARG13 arg13, ARG14 arg14) const
Definition bdlf_memfn.h:583
ResultType operator()(const INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4) const
Definition bdlf_memfn.h:646
ResultType operator()(INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6) const
Definition bdlf_memfn.h:459
ResultType operator()(INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8, ARG9 arg9, ARG10 arg10, ARG11 arg11) const
Definition bdlf_memfn.h:532
ResultType operator()(INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8, ARG9 arg9, ARG10 arg10, ARG11 arg11, ARG12 arg12, ARG13 arg13) const
Definition bdlf_memfn.h:565
ResultType operator()(const INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6, ARG7 arg7) const
Definition bdlf_memfn.h:686
ResultType operator()(const INSTANCE &object) const
Definition bdlf_memfn.h:601
ResultType operator()(INSTANCE &object) const
Definition bdlf_memfn.h:388
ResultType operator()(const INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8, ARG9 arg9, ARG10 arg10, ARG11 arg11, ARG12 arg12, ARG13 arg13, ARG14 arg14) const
Definition bdlf_memfn.h:801
Traits::ClassType ObjectType
Definition bdlf_memfn.h:306
ResultType operator()(const INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8, ARG9 arg9, ARG10 arg10, ARG11 arg11) const
Definition bdlf_memfn.h:747
PROTOTYPE Prototype
Definition bdlf_memfn.h:310
ResultType operator()(INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3) const
Definition bdlf_memfn.h:421
ResultType operator()(const INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6) const
Definition bdlf_memfn.h:672
ResultType operator()(INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4) const
Definition bdlf_memfn.h:433
Definition bslalg_constructorproxy.h:376
Definition bslma_allocator.h:545
Definition bslmf_forwardingtype.h:430
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:231
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
Definition bdlf_bind.h:979
Definition baljsn_encoder_testtypes.h:76
Definition bdlbb_blob.h:579
Definition bdlf_memfn.h:997
static MemFn< PROTOTYPE > memFn(PROTOTYPE func)
Definition bdlf_memfn.h:1255
Definition bdlf_memfn.h:237
static OBJTYPE & deref(TYPE &obj)
Definition bdlf_memfn.h:257
static OBJTYPE & derefImp(const TYPE &obj, bsl::true_type *)
Definition bdlf_memfn.h:251
static OBJTYPE & derefImp(OBJTYPE &obj, bsl::false_type *)
Definition bdlf_memfn.h:239
static OBJTYPE & deref(const TYPE &obj)
Definition bdlf_memfn.h:263
static OBJTYPE & derefImp(TYPE &obj, bsl::true_type *)
Definition bdlf_memfn.h:245
Definition bslmf_integralconstant.h:261
Definition bslma_usesbslmaallocator.h:344
Definition bslmf_haspointersemantics.h:83
Definition bslmf_isbitwisecopyable.h:298
Definition bslmf_isbitwisemoveable.h:718
Definition bslmf_memberfunctionpointertraits.h:150
Definition bslmf_nil.h:133