BDE 4.14.0 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
218
219
220
221namespace bdlf {
222 // =======================
223 // class MemFn_Dereference
224 // =======================
225
226/// This utility is used to convert user supplied values to references to
227/// `OBJTYPE` for object references that are directly convertible to
228/// `OBJTYPE`, the reference is returned directly. For pointers and objects
229/// that are not directly convertible (e.g., "smart pointers to `OBJTYPE`"),
230/// the result of `*OBJECT` is returned, where `OBJECT` is the pointer or
231/// object reference.
232template <class OBJTYPE>
234
235 static inline OBJTYPE& derefImp(OBJTYPE& obj, bsl::false_type *)
236 {
237 return obj;
238 }
239
240 template <class TYPE>
241 static inline OBJTYPE& derefImp(TYPE& obj, bsl::true_type *)
242 {
243 return *obj;
244 }
245
246 template <class TYPE>
247 static inline OBJTYPE& derefImp(const TYPE& obj, bsl::true_type *)
248 {
249 return *obj;
250 }
251
252 template <class TYPE>
253 static inline OBJTYPE& deref(TYPE& obj)
254 {
256 }
257
258 template <class TYPE>
259 static inline OBJTYPE& deref(const TYPE& obj)
260 {
262 }
263};
264
265 // ===========
266 // class MemFn
267 // ===========
268
269/// This class encapsulates a member function pointer having the
270/// parameterized `PROTOTYPE`, such that the member function pointer can be
271/// invoked in syntactically the same manner as a free function pointer.
272/// When invoking a member function through this wrapper, the first argument
273/// must be a pointer or reference to the instance on which to invoke the
274/// member function pointer. Zero to fourteen additional arguments may be
275/// specified depending on `PROTOTYPE`.
276///
277/// See @ref bdlf_memfn
278template <class PROTOTYPE>
279class MemFn {
280
281 // PRIVATE TYPES
283
284 // ASSERTIONS
285 BSLMF_ASSERT(Traits::IS_MEMBER_FUNCTION_PTR); // otherwise none of the
286 // 'typedef's below make any
287 // sense
288
289 public:
290 // TYPES
291
292 /// `ResultType` is an alias for the type of the object returned by an
293 /// invocation of this member function wrapper.
294 typedef typename Traits::ResultType ResultType;
295
296 /// `Args` is an alias for the list of arguments passed to an invocation
297 /// of this member function wrapper, expressed as a `bslmf_Typelist`.
298 typedef typename Traits::ArgumentList Args;
299
300 /// `ObjectType` is an alias for the class type to which the member
301 /// function that is wrapped belongs.
302 typedef typename Traits::ClassType ObjectType;
303
304 /// `ProtoType` is an alias for the parameterized `PROTOTYPE` passed as
305 /// a template argument to this wrapper.
306 typedef PROTOTYPE Prototype;
307
308 /// `ProtoType` is an alias for the parameterized `PROTOTYPE` passed as
309 /// a template argument to this wrapper.
310 ///
311 /// *DEPRECATED*: Use `Prototype` instead.
312 typedef PROTOTYPE ProtoType;
313
314 private:
315 // PRIVATE TYPES
316 typedef typename bslmf::ForwardingType<
318 typedef typename bslmf::ForwardingType<
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
343 /// `AN`, for `N` from 1 up to 14, is an alias for the type of the `N`th
344 /// argument in the `Args` list.
345 typedef typename bslmf::ForwardingType<
347
349
350 // DATA
351 PROTOTYPE d_func_p; // pointer to member function
352
353 public:
354 // CREATORS
355
356 /// Create a member function pointer wrapper holding the address of the
357 /// specified `func` member function having the parameterized
358 /// `PROTOTYPE`.
359 explicit
360 MemFn(PROTOTYPE func);
361
362 /// Create a member function pointer wrapper holding the address of the
363 /// same member function as the specified `original` object.
364 MemFn(const MemFn<PROTOTYPE>& original);
365
366 /// Destroy this object.
367 ~MemFn() = default;
368
369 // ACCESSORS
370
371 /// Invoke the member function pointer held by this wrapper on the
372 /// specified `object` reference to a modifiable instance of the
373 /// parameterized `INSTANCE` type, with no specified arguments, and
374 /// return the result of this invocation, or `void` if this member
375 /// function pointer does not return a result.
376 template <class INSTANCE>
377 ResultType operator()(INSTANCE& object) const
378 {
379 return (Deref::deref(object).*d_func_p)();
380 }
381
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 the specified argument `arg1`,
385 /// and 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, ARG1 arg1) const
389 {
390 return (Deref::deref(object).*d_func_p)(arg1); // see NOTES above
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` up
396 /// to `arg2`, and return the result of this invocation, or `void` if
397 /// this member function pointer does not return a result.
398 template <class INSTANCE>
399 ResultType operator()(INSTANCE& object, ARG1 arg1, ARG2 arg2) const
400 {
401 return (Deref::deref(object).*d_func_p)(arg1, arg2); // etc.
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 `arg3`, 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,
411 ARG1 arg1, ARG2 arg2, ARG3 arg3) const
412 {
413 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3);
414 }
415
416 /// Invoke the member function pointer held by this wrapper on the
417 /// specified `object` reference to a modifiable instance of the
418 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
419 /// to `arg4`, and return the result of this invocation, or `void` if
420 /// this member function pointer does not return a result.
421 template <class INSTANCE>
422 ResultType operator()(INSTANCE& object,
423 ARG1 arg1, ARG2 arg2, ARG3 arg3,
424 ARG4 arg4) const
425 {
426 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4);
427 }
428
429 /// Invoke the member function pointer held by this wrapper on the
430 /// specified `object` reference to a modifiable instance of the
431 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
432 /// to `arg5`, and return the result of this invocation, or `void` if
433 /// this member function pointer does not return a result.
434 template <class INSTANCE>
435 ResultType operator()(INSTANCE& object,
436 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
437 ARG5 arg5) const
438 {
439 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5);
440 }
441
442 /// Invoke the member function pointer held by this wrapper on the
443 /// specified `object` reference to a modifiable instance of the
444 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
445 /// to `arg6`, and return the result of this invocation, or `void` if
446 /// this member function pointer does not return a result.
447 template <class INSTANCE>
448 ResultType operator()(INSTANCE& object,
449 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
450 ARG5 arg5, ARG6 arg6) const
451 {
452 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
453 arg6);
454 }
455
456 /// Invoke the member function pointer held by this wrapper on the
457 /// specified `object` reference to a modifiable instance of the
458 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
459 /// to `arg7`, and return the result of this invocation, or `void` if
460 /// this member function pointer does not return a result.
461 template <class INSTANCE>
462 ResultType operator()(INSTANCE& object,
463 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
464 ARG5 arg5, ARG6 arg6, ARG7 arg7) const
465 {
466 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
467 arg6, arg7);
468 }
469
470 /// Invoke the member function pointer held by this wrapper on the
471 /// specified `object` reference to a modifiable instance of the
472 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
473 /// to `arg8`, and return the result of this invocation, or `void` if
474 /// this member function pointer does not return a result.
475 template <class INSTANCE>
476 ResultType operator()(INSTANCE& object,
477 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
478 ARG5 arg5, ARG6 arg6, ARG7 arg7,
479 ARG8 arg8) const
480 {
481 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
482 arg6, arg7, arg8);
483 }
484
485 /// Invoke the member function pointer held by this wrapper on the
486 /// specified `object` reference to a modifiable instance of the
487 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
488 /// to `arg9`, and return the result of this invocation, or `void` if
489 /// this member function pointer does not return a result.
490 template <class INSTANCE>
491 ResultType operator()(INSTANCE& object,
492 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
493 ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8,
494 ARG9 arg9) const
495 {
496 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
497 arg6, arg7, arg8, arg9);
498 }
499
500 /// Invoke the member function pointer held by this wrapper on the
501 /// specified `object` reference to a modifiable instance of the
502 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
503 /// to `arg10`, and return the result of this invocation, or `void` if
504 /// this member function pointer does not return a result.
505 template <class INSTANCE>
506 ResultType operator()(INSTANCE& object,
507 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
508 ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8,
509 ARG9 arg9, ARG10 arg10) const
510 {
511 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
512 arg6, arg7, arg8, arg9, arg10);
513 }
514
515 /// Invoke the member function pointer held by this wrapper on the
516 /// specified `object` reference to a modifiable instance of the
517 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
518 /// to `arg11`, and return the result of this invocation, or `void` if
519 /// this member function pointer does not return a result.
520 template <class INSTANCE>
521 ResultType operator()(INSTANCE& object,
522 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
523 ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8,
524 ARG9 arg9, ARG10 arg10, ARG11 arg11) const
525 {
526 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
527 arg6, arg7, arg8, arg9, arg10,
528 arg11);
529 }
530
531 /// Invoke the member function pointer held by this wrapper on the
532 /// specified `object` reference to a modifiable instance of the
533 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
534 /// to `arg12`, and return the result of this invocation, or `void` if
535 /// this member function pointer does not return a result.
536 template <class INSTANCE>
537 ResultType operator()(INSTANCE& object,
538 ARG1 arg1, ARG2 arg2, ARG3 arg3,
539 ARG4 arg4, ARG5 arg5, ARG6 arg6,
540 ARG7 arg7, ARG8 arg8, ARG9 arg9,
541 ARG10 arg10, ARG11 arg11, ARG12 arg12) const
542 {
543 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
544 arg6, arg7, arg8, arg9, arg10,
545 arg11, arg12);
546 }
547
548 /// Invoke the member function pointer held by this wrapper on the
549 /// specified `object` reference to a modifiable instance of the
550 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
551 /// to `arg13`, and return the result of this invocation, or `void` if
552 /// this member function pointer does not return a result.
553 template <class INSTANCE>
554 ResultType operator()(INSTANCE& object,
555 ARG1 arg1, ARG2 arg2, ARG3 arg3,
556 ARG4 arg4, ARG5 arg5, ARG6 arg6,
557 ARG7 arg7, ARG8 arg8, ARG9 arg9,
558 ARG10 arg10, ARG11 arg11, ARG12 arg12,
559 ARG13 arg13) const
560 {
561 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
562 arg6, arg7, arg8, arg9, arg10,
563 arg11, arg12, arg13);
564 }
565
566 /// Invoke the member function pointer held by this wrapper on the
567 /// specified `object` reference to a modifiable instance of the
568 /// parameterized `INSTANCE` type, with the specified argument `arg1` up
569 /// to `arg14`, and return the result of this invocation, or `void` if
570 /// this member function pointer does not return a result.
571 template <class INSTANCE>
572 ResultType operator()(INSTANCE& object,
573 ARG1 arg1, ARG2 arg2, ARG3 arg3,
574 ARG4 arg4, ARG5 arg5, ARG6 arg6,
575 ARG7 arg7, ARG8 arg8, ARG9 arg9,
576 ARG10 arg10, ARG11 arg11, ARG12 arg12,
577 ARG13 arg13, ARG14 arg14) const
578 {
579 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
580 arg6, arg7, arg8, arg9, arg10,
581 arg11, arg12, arg13, arg14);
582 }
583
584 /// Invoke the member function pointer held by this wrapper on the
585 /// specified `object` reference to a non-modifiable instance of the
586 /// parameterized `INSTANCE` type, with no arguments, and return the
587 /// result of this invocation, or `void` if this member function pointer
588 /// does not return a result.
589 template <class INSTANCE>
590 ResultType operator()(const INSTANCE& object) const
591 {
592 return (Deref::deref(object).*d_func_p)();
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 the specified argument `arg1`,
598 /// and return the result of this invocation, or `void` if this member
599 /// function pointer does not return a result.
600 template <class INSTANCE>
601 ResultType operator()(const INSTANCE& object, ARG1 arg1) const
602 {
603 return (Deref::deref(object).*d_func_p)(arg1);
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 arguments `arg1`
609 /// up to `arg2`, and return the result of this invocation, or `void` if
610 /// this member function pointer does not return a result.
611 template <class INSTANCE>
612 ResultType operator()(const INSTANCE& object, ARG1 arg1, ARG2 arg2) const
613 {
614 return (Deref::deref(object).*d_func_p)(arg1, arg2);
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 `arg3`, 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,
624 ARG1 arg1, ARG2 arg2, ARG3 arg3) const
625 {
626 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3);
627 }
628
629 /// Invoke the member function pointer held by this wrapper on the
630 /// specified `object` reference to a non-modifiable instance of the
631 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
632 /// up to `arg4`, and return the result of this invocation, or `void` if
633 /// this member function pointer does not return a result.
634 template <class INSTANCE>
635 ResultType operator()(const INSTANCE& object,
636 ARG1 arg1, ARG2 arg2, ARG3 arg3,
637 ARG4 arg4) const
638 {
639 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4);
640 }
641
642 /// Invoke the member function pointer held by this wrapper on the
643 /// specified `object` reference to a non-modifiable instance of the
644 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
645 /// up to `arg5`, and return the result of this invocation, or `void` if
646 /// this member function pointer does not return a result.
647 template <class INSTANCE>
648 ResultType operator()(const INSTANCE& object,
649 ARG1 arg1, ARG2 arg2, ARG3 arg3,
650 ARG4 arg4, ARG5 arg5) const
651 {
652 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5);
653 }
654
655 /// Invoke the member function pointer held by this wrapper on the
656 /// specified `object` reference to a non-modifiable instance of the
657 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
658 /// up to `arg6`, and return the result of this invocation, or `void` if
659 /// this member function pointer does not return a result.
660 template <class INSTANCE>
661 ResultType operator()(const INSTANCE& object,
662 ARG1 arg1, ARG2 arg2, ARG3 arg3,
663 ARG4 arg4, ARG5 arg5, ARG6 arg6) const
664 {
665 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
666 arg6);
667 }
668
669 /// Invoke the member function pointer held by this wrapper on the
670 /// specified `object` reference to a non-modifiable instance of the
671 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
672 /// up to `arg7`, and return the result of this invocation, or `void` if
673 /// this member function pointer does not return a result.
674 template <class INSTANCE>
675 ResultType operator()(const INSTANCE& object,
676 ARG1 arg1, ARG2 arg2, ARG3 arg3,
677 ARG4 arg4, ARG5 arg5, ARG6 arg6,
678 ARG7 arg7) const
679 {
680 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
681 arg6, arg7);
682 }
683
684 /// Invoke the member function pointer held by this wrapper on the
685 /// specified `object` reference to a non-modifiable instance of the
686 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
687 /// up to `arg8`, and return the result of this invocation, or `void` if
688 /// this member function pointer does not return a result.
689 template <class INSTANCE>
690 ResultType operator()(const INSTANCE& object,
691 ARG1 arg1, ARG2 arg2, ARG3 arg3,
692 ARG4 arg4, ARG5 arg5, ARG6 arg6,
693 ARG7 arg7, ARG8 arg8) const
694 {
695 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
696 arg6, arg7, arg8);
697 }
698
699 /// Invoke the member function pointer held by this wrapper on the
700 /// specified `object` reference to a non-modifiable instance of the
701 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
702 /// up to `arg9`, and return the result of this invocation, or `void` if
703 /// this member function pointer does not return a result.
704 template <class INSTANCE>
705 ResultType operator()(const INSTANCE& object,
706 ARG1 arg1, ARG2 arg2, ARG3 arg3,
707 ARG4 arg4, ARG5 arg5, ARG6 arg6,
708 ARG7 arg7, ARG8 arg8, ARG9 arg9) const
709 {
710 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
711 arg6, arg7, arg8, arg9);
712 }
713
714 /// Invoke the member function pointer held by this wrapper on the
715 /// specified `object` reference to a non-modifiable instance of the
716 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
717 /// up to `arg10`, and return the result of this invocation, or `void`
718 /// if this member function pointer does not return a result.
719 template <class INSTANCE>
720 ResultType operator()(const INSTANCE& object,
721 ARG1 arg1, ARG2 arg2, ARG3 arg3,
722 ARG4 arg4, ARG5 arg5, ARG6 arg6,
723 ARG7 arg7, ARG8 arg8, ARG9 arg9,
724 ARG10 arg10) const
725 {
726 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
727 arg6, arg7, arg8, arg9, arg10);
728 }
729
730 /// Invoke the member function pointer held by this wrapper on the
731 /// specified `object` reference to a non-modifiable instance of the
732 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
733 /// up to `arg11`, and return the result of this invocation, or `void`
734 /// if this member function pointer does not return a result.
735 template <class INSTANCE>
736 ResultType operator()(const INSTANCE& object,
737 ARG1 arg1, ARG2 arg2, ARG3 arg3,
738 ARG4 arg4, ARG5 arg5, ARG6 arg6,
739 ARG7 arg7, ARG8 arg8, ARG9 arg9,
740 ARG10 arg10, ARG11 arg11) const
741 {
742 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
743 arg6, arg7, arg8, arg9, arg10,
744 arg11);
745 }
746
747 /// Invoke the member function pointer held by this wrapper on the
748 /// specified `object` reference to a non-modifiable instance of the
749 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
750 /// up to `arg12`, and return the result of this invocation, or `void`
751 /// if this member function pointer does not return a result.
752 template <class INSTANCE>
753 ResultType operator()(const INSTANCE& object,
754 ARG1 arg1, ARG2 arg2, ARG3 arg3,
755 ARG4 arg4, ARG5 arg5, ARG6 arg6,
756 ARG7 arg7, ARG8 arg8, ARG9 arg9,
757 ARG10 arg10, ARG11 arg11,
758 ARG12 arg12) const
759 {
760 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
761 arg6, arg7, arg8, arg9, arg10,
762 arg11, arg12);
763 }
764
765 /// Invoke the member function pointer held by this wrapper on the
766 /// specified `object` reference to a non-modifiable instance of the
767 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
768 /// up to `arg13`, and return the result of this invocation, or `void`
769 /// if this member function pointer does not return a result.
770 template <class INSTANCE>
771 ResultType operator()(const INSTANCE& object,
772 ARG1 arg1, ARG2 arg2, ARG3 arg3,
773 ARG4 arg4, ARG5 arg5, ARG6 arg6,
774 ARG7 arg7, ARG8 arg8, ARG9 arg9,
775 ARG10 arg10, ARG11 arg11, ARG12 arg12,
776 ARG13 arg13) const
777 {
778 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4,
779 arg5, arg6, arg7, arg8,
780 arg9, arg10, arg11, arg12,
781 arg13);
782 }
783
784 /// Invoke the member function pointer held by this wrapper on the
785 /// specified `object` reference to a non-modifiable instance of the
786 /// parameterized `INSTANCE` type, with the specified arguments `arg1`
787 /// up to `arg14`, and return the result of this invocation, or `void`
788 /// if this member function pointer does not return a result.
789 template <class INSTANCE>
790 ResultType operator()(const INSTANCE& object,
791 ARG1 arg1, ARG2 arg2, ARG3 arg3,
792 ARG4 arg4, ARG5 arg5, ARG6 arg6,
793 ARG7 arg7, ARG8 arg8, ARG9 arg9,
794 ARG10 arg10, ARG11 arg11, ARG12 arg12,
795 ARG13 arg13, ARG14 arg14) const
796 {
797 return (Deref::deref(object).*d_func_p)(arg1, arg2, arg3, arg4, arg5,
798 arg6, arg7, arg8, arg9, arg10,
799 arg11, arg12, arg13, arg14);
800 }
801};
802
803 // ===================
804 // class MemFnInstance
805 // ===================
806
807/// This class encapsulates a member function pointer having the
808/// parameterized `PROTOTYPE` and a value of the parameterized `INSTANCE`
809/// type, which can be either be the type of object referred to by the
810/// `PROTOTYPE`, or a pointer to one, such that the member function pointer
811/// can be invoked on the wrapped instance in syntactically the same manner
812/// as a free function pointer. Zero to fourteen additional arguments may
813/// be specified depending on the `PROTOTYPE`. Note that whether `INSTANCE`
814/// is a pointer or an object is determined by whether it has pointer
815/// semantics or not (as determined by the `bslmf::HasPointerSemantics` type
816/// trait). Also note that if `INSTANCE` is an object that does not have
817/// pointer semantics, `PROTOTYPE` must be const-qualified.
818///
819/// See @ref bdlf_memfn
820template <class PROTOTYPE, class INSTANCE>
822
823 // PRIVATE TYPES
825
826 public:
827 // TYPES
828
829 /// `ResultType` is an alias for the type of the object returned by an
830 /// invocation of this member function wrapper.
831 typedef typename Traits::ResultType ResultType;
832
833 /// `Args` is an alias for the list of arguments passed to an invocation
834 /// of this member function wrapper, expressed as a `bslmf_Typelist`.
835 typedef typename Traits::ArgumentList Args;
836
837 /// `ObjectType` is an alias for the class type to which the member
838 /// function that is wrapped belongs.
839 typedef typename Traits::ClassType ObjectType;
840
841 /// `ProtoType` is an alias for the parameterized `PROTOTYPE` passed as
842 /// a template argument to this wrapper.
843 typedef PROTOTYPE Prototype;
844
845 /// `ProtoType` is an alias for the parameterized `PROTOTYPE` passed as
846 /// a template argument to this wrapper.
847 ///
848 /// @deprecated Use @ref Prototype instead.
849 typedef PROTOTYPE ProtoType;
850
852
853
854 private:
855 // PRIVATE TYPES
856 typedef typename bslmf::ForwardingType<
858 typedef typename bslmf::ForwardingType<
860 typedef typename bslmf::ForwardingType<
862 typedef typename bslmf::ForwardingType<
864 typedef typename bslmf::ForwardingType<
866 typedef typename bslmf::ForwardingType<
868 typedef typename bslmf::ForwardingType<
870 typedef typename bslmf::ForwardingType<
872 typedef typename bslmf::ForwardingType<
874 typedef typename bslmf::ForwardingType<
876 typedef typename bslmf::ForwardingType<
878 typedef typename bslmf::ForwardingType<
880 typedef typename bslmf::ForwardingType<
882
883 /// `AN`, for `N` from 1 up to 14, is an alias for the type of the `N`th
884 /// argument in the `Args` list.
885 typedef typename bslmf::ForwardingType<
887
888 // DATA
889 PROTOTYPE d_func_p; // pointer to member function
890
891 bslalg::ConstructorProxy<INSTANCE> d_obj; // object instance, or
892 // pointer to such
893
894 // PRIVATE ACCESSORS
895 public:
896 // CREATORS
897
898 /// Create a member function pointer wrapper around the specified `func`
899 /// member function pointer of the parameterized `PROTOTYPE`, that is
900 /// invocable on the specified `object` instance of the parameterized
901 /// `INSTANCE`. Optionally specify a `basicAllocator` used to supply
902 /// memory. If `basicAllocator` is 0, the currently installed default
903 /// allocator is used.
904 MemFnInstance(PROTOTYPE func,
905 const INSTANCE& object,
906 bslma::Allocator *basicAllocator = 0);
907
908 /// Create a member function pointer wrapper around the same member
909 /// function and instance pointed to by the specified `original` object.
910 /// Optionally specify a `basicAllocator` used to supply memory. If
911 /// `basicAllocator` is 0, the currently installed default allocator is
912 /// used.
913 MemFnInstance(const MemFnInstance& original,
914 bslma::Allocator *basicAllocator = 0);
915
916 /// Destroy this object.
918
919 // MANIPULATORS
920
921 /// Assign to this member function pointer wrapper the same member
922 /// function and instance pointed to by the specified `rhs` member
923 /// function pointer wrapper, and return a reference to this modifiable
924 /// member function pointer wrapper.
926
927 // ACCESSORS
928
929 /// Invoke the member function pointer held by this wrapper on the
930 /// provided object with the specified `arg1` up to `argN` as arguments,
931 /// with `N` being the number of arguments of the member function, and
932 /// return the result of this invocation, or `void` if this member
933 /// function pointer does not return a result.
934 ResultType operator()() const;
935 ResultType operator()(ARG1 arg1) const;
936 ResultType operator()(ARG1 arg1, ARG2 arg2) const;
937 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3) const;
938 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4) const;
939 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
940 ARG5 arg5) const;
941 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
942 ARG5 arg5, ARG6 arg6) const;
943 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
944 ARG5 arg5, ARG6 arg6,
945 ARG7 arg7) const;
946 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
947 ARG5 arg5, ARG6 arg6,
948 ARG7 arg7, ARG8 arg8) const;
949 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
950 ARG5 arg5, ARG6 arg6,
951 ARG7 arg7, ARG8 arg8, ARG9 arg9) const;
952 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
953 ARG5 arg5, ARG6 arg6,
954 ARG7 arg7, ARG8 arg8, ARG9 arg9, ARG10 arg10) const;
955 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
956 ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8,
957 ARG9 arg9, ARG10 arg10, ARG11 arg11) const;
958 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
959 ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8,
960 ARG9 arg9, ARG10 arg10, ARG11 arg11,
961 ARG12 arg12) const;
962 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
963 ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8,
964 ARG9 arg9, ARG10 arg10, ARG11 arg11, ARG12 arg12,
965 ARG13 arg13) const;
966 ResultType operator()(ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4,
967 ARG5 arg5, ARG6 arg6, ARG7 arg7, ARG8 arg8,
968 ARG9 arg9, ARG10 arg10, ARG11 arg11, ARG12 arg12,
969 ARG13 arg13, ARG14 arg14) const;
970};
971
972 // ================
973 // struct MemFnUtil
974 // ================
975
976/// The methods provided in this utility are used for constructing `MemFn`
977/// and `MemFnInstance` objects from function pointers.
978struct MemFnUtil {
979
980 // CLASS METHODS
981
982 /// Return a `MemFn` member function wrapper that encapsulates the
983 /// specified `func` member function pointer of the parameterized
984 /// `PROTOTYPE`.
985 template <class PROTOTYPE>
986 static
987 MemFn<PROTOTYPE> memFn(PROTOTYPE func);
988
989 /// Return a `MemFnInstance` member function wrapper that encapsulates
990 /// the specified `func` member function pointer of the parameterized
991 /// `PROTOTYPE` and the specified `object` instance of the parameterized
992 /// `INSTANCE` type.
993 template <class PROTOTYPE, class INSTANCE>
994 static
996 const INSTANCE& object);
997};
998
999// ============================================================================
1000// INLINE FUNCTION DEFINITIONS
1001// ============================================================================
1002
1003 // -----------
1004 // class MemFn
1005 // -----------
1006
1007// CREATORS
1008template <class PROTOTYPE>
1009inline
1011: d_func_p(func)
1012{
1013}
1014
1015template <class PROTOTYPE>
1016inline
1018: d_func_p(original.d_func_p)
1019{
1020}
1021
1022 // -------------------
1023 // class MemFnInstance
1024 // -------------------
1025
1026// CREATORS
1027template <class PROTOTYPE, class INSTANCE>
1028inline
1030 const MemFnInstance<PROTOTYPE, INSTANCE>& original,
1031 bslma::Allocator *basicAllocator)
1032: d_func_p(original.d_func_p)
1033, d_obj(original.d_obj, bslma::Default::allocator(basicAllocator))
1034{
1035}
1036
1037template <class PROTOTYPE, class INSTANCE>
1038inline
1040 PROTOTYPE func,
1041 const INSTANCE& object,
1042 bslma::Allocator *basicAllocator)
1043: d_func_p(func)
1044, d_obj(object, bslma::Default::allocator(basicAllocator))
1045{
1046}
1047
1048template <class PROTOTYPE, class INSTANCE>
1049inline
1053
1054// MANIPULATORS
1055template <class PROTOTYPE, class INSTANCE>
1056inline
1059 const MemFnInstance& rhs)
1060{
1061 d_func_p = rhs.d_func_p;
1062 d_obj.object() = rhs.d_obj.object();
1063 return *this;
1064}
1065
1066// ACCESSORS
1067template <class PROTOTYPE, class INSTANCE>
1068inline
1071{
1072 return (Deref::deref(d_obj.object()).*d_func_p)();
1073}
1074
1075template <class PROTOTYPE, class INSTANCE>
1076inline
1079{
1080 return (Deref::deref(d_obj.object()).*d_func_p)(arg1);
1081}
1082
1083template <class PROTOTYPE, class INSTANCE>
1084inline
1087{
1088 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2);
1089}
1090
1091template <class PROTOTYPE, class INSTANCE>
1092inline
1095 ARG1 arg1, ARG2 arg2, ARG3 arg3) const
1096{
1097 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3);
1098}
1099
1100template <class PROTOTYPE, class INSTANCE>
1101inline
1104 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4) const
1105{
1106 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3, arg4);
1107}
1108
1109template <class PROTOTYPE, class INSTANCE>
1110inline
1113 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5) const
1114{
1115 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3, arg4,
1116 arg5);
1117}
1118
1119template <class PROTOTYPE, class INSTANCE>
1120inline
1123 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6) const
1124{
1125 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3, arg4,
1126 arg5, arg6);
1127}
1128
1129template <class PROTOTYPE, class INSTANCE>
1130inline
1133 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6,
1134 ARG7 arg7) const
1135{
1136 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3, arg4,
1137 arg5, arg6, arg7);
1138}
1139
1140template <class PROTOTYPE, class INSTANCE>
1141inline
1144 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6,
1145 ARG7 arg7, ARG8 arg8) const
1146{
1147 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3, arg4,
1148 arg5, arg6, arg7, arg8);
1149}
1150
1151template <class PROTOTYPE, class INSTANCE>
1152inline
1155 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6,
1156 ARG7 arg7, ARG8 arg8, ARG9 arg9) const
1157{
1158 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3, arg4,
1159 arg5, arg6, arg7, arg8,
1160 arg9);
1161}
1162
1163template <class PROTOTYPE, class INSTANCE>
1164inline
1167 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6,
1168 ARG7 arg7, ARG8 arg8, ARG9 arg9, ARG10 arg10) const
1169{
1170 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3, arg4,
1171 arg5, arg6, arg7, arg8,
1172 arg9, arg10);
1173}
1174
1175template <class PROTOTYPE, class INSTANCE>
1176inline
1179 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6,
1180 ARG7 arg7, ARG8 arg8, ARG9 arg9, ARG10 arg10, ARG11 arg11) const
1181{
1182 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3, arg4,
1183 arg5, arg6, arg7, arg8,
1184 arg9, arg10, arg11);
1185}
1186
1187template <class PROTOTYPE, class INSTANCE>
1188inline
1191 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6,
1192 ARG7 arg7, ARG8 arg8, ARG9 arg9, ARG10 arg10, ARG11 arg11,
1193 ARG12 arg12) const
1194{
1195 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3, arg4,
1196 arg5, arg6, arg7, arg8,
1197 arg9, arg10, arg11, arg12);
1198}
1199
1200template <class PROTOTYPE, class INSTANCE>
1201inline
1204 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6,
1205 ARG7 arg7, ARG8 arg8, ARG9 arg9, ARG10 arg10, ARG11 arg11,
1206 ARG12 arg12, ARG13 arg13) const
1207{
1208 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3, arg4,
1209 arg5, arg6, arg7, arg8,
1210 arg9, arg10, arg11, arg12,
1211 arg13);
1212}
1213
1214template <class PROTOTYPE, class INSTANCE>
1215inline
1218 ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5,
1219 ARG6 arg6, ARG7 arg7, ARG8 arg8, ARG9 arg9, ARG10 arg10,
1220 ARG11 arg11, ARG12 arg12, ARG13 arg13, ARG14 arg14) const
1221{
1222 return (Deref::deref(d_obj.object()).*d_func_p)(arg1, arg2, arg3, arg4,
1223 arg5, arg6, arg7, arg8,
1224 arg9, arg10, arg11, arg12,
1225 arg13, arg14);
1226}
1227
1228 // ----------------
1229 // struct MemFnUtil
1230 // ----------------
1231
1232// CLASS METHODS
1233template <class PROTOTYPE>
1234inline
1236MemFnUtil::memFn(PROTOTYPE func)
1237{
1238 return MemFn<PROTOTYPE>(func);
1239}
1240
1241template <class PROTOTYPE, class INSTANCE>
1242inline
1244MemFnUtil::memFn(PROTOTYPE func, const INSTANCE& object)
1245{
1246 return MemFnInstance<PROTOTYPE, INSTANCE>(func, object);
1247}
1248
1249} // close package namespace
1250
1251
1252// ============================================================================
1253// TYPE TRAITS
1254// ============================================================================
1255
1256
1257namespace bslma {
1258
1259template <class PROTOTYPE, class INSTANCE>
1260struct UsesBslmaAllocator<bdlf::MemFnInstance<PROTOTYPE, INSTANCE> > :
1262{};
1263
1264} // close namespace bslma
1265namespace bslmf {
1266
1267template <class PROTOTYPE, class INSTANCE>
1268struct IsBitwiseMoveable<bdlf::MemFnInstance<PROTOTYPE, INSTANCE> > :
1269 IsBitwiseMoveable<INSTANCE>
1270{};
1271
1272/// This bitwise moveable trait is redundant as it is already implied by the
1273/// `bslmf::IsBitwiseCopyable` trait below. We retain this definition,
1274/// however, as it can potentially save a level of template instantiation.
1275template <class PROTOTYPE>
1276struct IsBitwiseMoveable<bdlf::MemFn<PROTOTYPE> > : bsl::true_type
1277{
1278};
1279
1280template <class PROTOTYPE>
1281struct IsBitwiseCopyable<bdlf::MemFn<PROTOTYPE> > : bsl::true_type
1282{};
1283
1284} // close namespace bslmf
1285
1286
1287#endif
1288
1289// ----------------------------------------------------------------------------
1290// Copyright 2015 Bloomberg Finance L.P.
1291//
1292// Licensed under the Apache License, Version 2.0 (the "License");
1293// you may not use this file except in compliance with the License.
1294// You may obtain a copy of the License at
1295//
1296// http://www.apache.org/licenses/LICENSE-2.0
1297//
1298// Unless required by applicable law or agreed to in writing, software
1299// distributed under the License is distributed on an "AS IS" BASIS,
1300// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1301// See the License for the specific language governing permissions and
1302// limitations under the License.
1303// ----------------------------- END-OF-FILE ----------------------------------
1304
1305/** @} */
1306/** @} */
1307/** @} */
Definition bdlf_memfn.h:821
Traits::ClassType ObjectType
Definition bdlf_memfn.h:839
MemFn_Dereference< ObjectType > Deref
Definition bdlf_memfn.h:851
MemFnInstance(PROTOTYPE func, const INSTANCE &object, bslma::Allocator *basicAllocator=0)
Definition bdlf_memfn.h:1039
PROTOTYPE ProtoType
Definition bdlf_memfn.h:849
~MemFnInstance()
Destroy this object.
Definition bdlf_memfn.h:1050
Traits::ArgumentList Args
Definition bdlf_memfn.h:835
MemFnInstance & operator=(const MemFnInstance &rhs)
Definition bdlf_memfn.h:1058
PROTOTYPE Prototype
Definition bdlf_memfn.h:843
ResultType operator()() const
Definition bdlf_memfn.h:1070
Traits::ResultType ResultType
Definition bdlf_memfn.h:831
Definition bdlf_memfn.h:279
ResultType operator()(INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6, ARG7 arg7) const
Definition bdlf_memfn.h:462
ResultType operator()(const INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5) const
Definition bdlf_memfn.h:648
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:690
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:476
ResultType operator()(INSTANCE &object, ARG1 arg1, ARG2 arg2) const
Definition bdlf_memfn.h:399
ResultType operator()(const INSTANCE &object, ARG1 arg1) const
Definition bdlf_memfn.h:601
ResultType operator()(const INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3) 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) const
Definition bdlf_memfn.h:705
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:537
PROTOTYPE ProtoType
Definition bdlf_memfn.h:312
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:506
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:753
Traits::ResultType ResultType
Definition bdlf_memfn.h:294
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:491
~MemFn()=default
Destroy this object.
ResultType operator()(const INSTANCE &object, ARG1 arg1, ARG2 arg2) const
Definition bdlf_memfn.h:612
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:771
ResultType operator()(INSTANCE &object, ARG1 arg1) const
Definition bdlf_memfn.h:388
ResultType operator()(INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5) const
Definition bdlf_memfn.h:435
Traits::ArgumentList Args
Definition bdlf_memfn.h:298
MemFn(PROTOTYPE func)
Definition bdlf_memfn.h:1010
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:720
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:572
ResultType operator()(const INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4) const
Definition bdlf_memfn.h:635
ResultType operator()(INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6) const
Definition bdlf_memfn.h:448
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:521
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:554
ResultType operator()(const INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6, ARG7 arg7) const
Definition bdlf_memfn.h:675
ResultType operator()(const INSTANCE &object) const
Definition bdlf_memfn.h:590
ResultType operator()(INSTANCE &object) const
Definition bdlf_memfn.h:377
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:790
Traits::ClassType ObjectType
Definition bdlf_memfn.h:302
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:736
PROTOTYPE Prototype
Definition bdlf_memfn.h:306
ResultType operator()(INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3) const
Definition bdlf_memfn.h:410
ResultType operator()(const INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, ARG6 arg6) const
Definition bdlf_memfn.h:661
ResultType operator()(INSTANCE &object, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4) const
Definition bdlf_memfn.h:422
Definition bslalg_constructorproxy.h:368
OBJECT_TYPE & object() BSLS_KEYWORD_NOEXCEPT
Return a reference to the modifiable object held by this proxy.
Definition bslalg_constructorproxy.h:1187
Definition bslma_allocator.h:457
Definition bslmf_forwardingtype.h:428
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:229
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdlf_bind.h:976
Definition balxml_encoderoptions.h:68
Definition bdlbb_blob.h:576
Definition bdlf_memfn.h:978
static MemFn< PROTOTYPE > memFn(PROTOTYPE func)
Definition bdlf_memfn.h:1236
Definition bdlf_memfn.h:233
static OBJTYPE & deref(TYPE &obj)
Definition bdlf_memfn.h:253
static OBJTYPE & derefImp(const TYPE &obj, bsl::true_type *)
Definition bdlf_memfn.h:247
static OBJTYPE & derefImp(OBJTYPE &obj, bsl::false_type *)
Definition bdlf_memfn.h:235
static OBJTYPE & deref(const TYPE &obj)
Definition bdlf_memfn.h:259
static OBJTYPE & derefImp(TYPE &obj, bsl::true_type *)
Definition bdlf_memfn.h:241
Definition bslmf_integralconstant.h:244
Definition bslma_usesbslmaallocator.h:343
Definition bslmf_haspointersemantics.h:78
Definition bslmf_isbitwisecopyable.h:298
Definition bslmf_isbitwisemoveable.h:718
Definition bslmf_memberfunctionpointertraits.h:150
This struct is empty and represents a nil type.
Definition bslmf_nil.h:131