1
+ # -*- mode : snippet -*-
2
+ # name : class11
3
+ # key : cls11
4
+ # group : c++11
5
+ # uuid : d7c41f87-9b8a-479d-bb12-89f4cbdd46a7
6
+ # contributor : Ved Vyas
7
+ # desc : Snippet for C++11 classes based on c++-mode/class. Allows for Rule of
8
+ # [0, All]. A choice between ";", " = default;", and " = delete;" is presented
9
+ # for each method. The methods and some of the optional keywords/specifiers are
10
+ # exposed as fields that users can easily skip-and-clear.
11
+ # Hackish query-replace-regexp to renumber non-mirror fields in the region
12
+ # between public and protected (can use N as a field number in the snippet) :
13
+ # \${[0-9N]* :\([^\$]\) -> ${\,(+ 2 \#):\1
14
+ # References :
15
+ # 1. http ://en.cppreference.com/w/cpp/language/rule_of_three#Rule_of_five
16
+ # 2. https ://en.wikipedia.org/wiki/Rule_of_three_%28C%2B%2B_programming%29#Example_in_C.2B.2B
17
+ # 3. http ://stackoverflow.com/a/4782927
18
+ # --
19
+ class ${ 1 :Name }
20
+ {
21
+ public:
22
+ ${ 2 : ${ 3 ://! Default constructor
23
+ } ${ 1 :$ (doom-snippets-c++-class-name yas-text) } ()${ 4 :;$ (doom-snippets-c++-class-method-decl-choice) }
24
+
25
+ } ${ 5 : ${ 6 ://! Copy constructor
26
+ } ${ 1 :$ (doom-snippets-c++-class-name yas-text) } (const ${ 1 :$ (doom-snippets-c++-class-name yas-text) } &other)${ 7 :;$ (doom-snippets-c++-class-method-decl-choice) }
27
+
28
+ } ${ 8 : ${ 9 ://! Move constructor
29
+ } ${ 1 :$ (doom-snippets-c++-class-name yas-text) } (${ 1 :$ (doom-snippets-c++-class-name yas-text) } &&other)${ 10 : noexcept } ${ 11 :;$ (doom-snippets-c++-class-method-decl-choice) }
30
+
31
+ } ${ 12 : ${ 13 ://! Destructor
32
+ } ${ 14 :virtual } ~${ 1 :$ (doom-snippets-c++-class-name yas-text) } ()${ 15 : noexcept } ${ 16 :;$ (doom-snippets-c++-class-method-decl-choice) }
33
+
34
+ } ${ 17 : ${ 18 ://! Copy assignment operator
35
+ } ${ 1 :$ (doom-snippets-c++-class-name yas-text) } & operator=(const ${ 1 :$ (doom-snippets-c++-class-name yas-text) } &other)${ 19 :;$ (doom-snippets-c++-class-method-decl-choice) }
36
+
37
+ } ${ 20 : ${ 21 ://! Move assignment operator
38
+ } ${ 1 :$ (doom-snippets-c++-class-name yas-text) } & operator=(${ 1 :$ (doom-snippets-c++-class-name yas-text) } &&other)${ 22 : noexcept } ${ 23 :;$ (doom-snippets-c++-class-method-decl-choice) }
39
+
40
+ } $0
41
+
42
+ protected:
43
+ private:
44
+ };
0 commit comments