From Jason Turner

[func.wrap.move.class]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpy3flig4h/{from.md → to.md} +55 -0
tmp/tmpy3flig4h/{from.md → to.md} RENAMED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ##### Class template `move_only_function` <a id="func.wrap.move.class">[[func.wrap.move.class]]</a>
2
+
3
+ ``` cpp
4
+ namespace std {
5
+ template<class... S> class move_only_function; // not defined
6
+
7
+ template<class R, class... ArgTypes>
8
+ class move_only_function<R(ArgTypes...) cv ref noexcept(noex)> {
9
+ public:
10
+ using result_type = R;
11
+
12
+ // [func.wrap.move.ctor], constructors, assignment, and destructor
13
+ move_only_function() noexcept;
14
+ move_only_function(nullptr_t) noexcept;
15
+ move_only_function(move_only_function&&) noexcept;
16
+ template<class F> move_only_function(F&&);
17
+ template<class T, class... Args>
18
+ explicit move_only_function(in_place_type_t<T>, Args&&...);
19
+ template<class T, class U, class... Args>
20
+ explicit move_only_function(in_place_type_t<T>, initializer_list<U>, Args&&...);
21
+
22
+ move_only_function& operator=(move_only_function&&);
23
+ move_only_function& operator=(nullptr_t) noexcept;
24
+ template<class F> move_only_function& operator=(F&&);
25
+
26
+ ~move_only_function();
27
+
28
+ // [func.wrap.move.inv], invocation
29
+ explicit operator bool() const noexcept;
30
+ R operator()(ArgTypes...) cv ref noexcept(noex);
31
+
32
+ // [func.wrap.move.util], utility
33
+ void swap(move_only_function&) noexcept;
34
+ friend void swap(move_only_function&, move_only_function&) noexcept;
35
+ friend bool operator==(const move_only_function&, nullptr_t) noexcept;
36
+
37
+ private:
38
+ template<class VT>
39
+ static constexpr bool is-callable-from = see below; // exposition only
40
+ };
41
+ }
42
+ ```
43
+
44
+ The `move_only_function` class template provides polymorphic wrappers
45
+ that generalize the notion of a callable object [[func.def]]. These
46
+ wrappers can store, move, and call arbitrary callable objects, given a
47
+ call signature.
48
+
49
+ *Recommended practice:* Implementations should avoid the use of
50
+ dynamically allocated memory for a small contained value.
51
+
52
+ [*Note 1*: Such small-object optimization can only be applied to a type
53
+ `T` for which `is_nothrow_move_constructible_v<T>` is
54
+ `true`. — *end note*]
55
+