3 #ifndef __CDS_OPT_ITEM_DISPOSER_H
4 #define __CDS_OPT_ITEM_DISPOSER_H
6 #include <cds/details/defs.h>
8 namespace cds { namespace opt {
10 /// [type-option] value cleaning
12 The cleaner is a functor called when an item is removed from a container.
13 Note, the cleaner should not delete (deallocate) the value \p val passed in.
14 However, if the \p value_type type is a structure that contains dynamically allocated
15 field(s), the cleaning functor may deallocate it and iniitalize to default value (usually, \p nullptr).
17 The interface for type \p value_type is:
20 void operator ()( value_type& val )
23 // code to cleanup \p val
28 Predefined option types:
29 \li opt::v::empty_cleaner
31 template <typename Type>
32 struct value_cleaner {
34 template <typename BASE> struct pack: public BASE
36 typedef Type value_cleaner;
45 One of available type for opt::value_cleaner option.
46 This cleaner is empty, i.e. it does not do any cleaning.
52 void operator()( T& /*val*/ )
57 /// Cleaner that calls destructor of type \p T
59 One of available type for opt::value_cleaner option.
61 struct destruct_cleaner
65 void operator()( T& val )
74 }} // namespace cds::opt
76 #endif // #ifndef __CDS_OPT_ITEM_DISPOSER_H