c++ snippets
This commit is contained in:
parent
2273b2fddf
commit
3bcbb4dc6c
|
@ -0,0 +1,7 @@
|
|||
# -*- mode: snippet -*-
|
||||
# name: operator!=
|
||||
# key: !=
|
||||
# --
|
||||
bool ${1:MyClass}::operator!=(const $1 &other) const {
|
||||
return !(*this == other);
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
# -*- mode: snippet -*-
|
||||
# name: operator+
|
||||
# key: +
|
||||
# --
|
||||
${1://we need to have defined already the +=}
|
||||
const ${2:MyClass} $2::operator+(const $2 &other) const {
|
||||
$2 result = *this;
|
||||
result += other;
|
||||
return result;
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
# -*- mode: snippet -*-
|
||||
# name: operator+=
|
||||
# key: +=
|
||||
# --
|
||||
${1:MyClass} & $1::operator+=(const $1 &rhs) {
|
||||
$0
|
||||
return *this;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
# -*- mode: snippet -*-
|
||||
# name: operator=
|
||||
# key: =
|
||||
# where this is a reference to myself
|
||||
# --
|
||||
${1:MyClass} & $1::operator=(const $1 &rhs) {
|
||||
// Check for self-assignment!
|
||||
if (this == &rhs) // Same object?
|
||||
return *this; // Yes, so skip assignment, and just return *this.
|
||||
$0
|
||||
return *this;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
# -*- mode: snippet -*-
|
||||
# name: operator==
|
||||
# key: ==
|
||||
# --
|
||||
bool ${1:MyClass}::operator==(const $1 &other) const {
|
||||
$0
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
# -*- mode: snippet -*-
|
||||
# name: private
|
||||
# key: pr
|
||||
# --
|
||||
private:
|
||||
$0
|
|
@ -1,6 +1,6 @@
|
|||
# -*- mode: snippet -*-
|
||||
# name: protected
|
||||
# key: proc
|
||||
# key: pt
|
||||
# --
|
||||
protected:
|
||||
$0
|
|
@ -1,6 +1,6 @@
|
|||
# -*- mode: snippet -*-
|
||||
# name: public
|
||||
# key: pub
|
||||
# key: pb
|
||||
# --
|
||||
public:
|
||||
$0
|
|
@ -0,0 +1,5 @@
|
|||
# -*- mode: snippet -*-
|
||||
# name: this
|
||||
# key: th
|
||||
# --
|
||||
this
|
Loading…
Reference in New Issue