c++ snippets

This commit is contained in:
Andrea Crotti 2010-09-13 19:14:16 +02:00
parent 2273b2fddf
commit 3bcbb4dc6c
18 changed files with 57 additions and 2 deletions

7
c++-mode/operator!= Normal file
View File

@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: operator!=
# key: !=
# --
bool ${1:MyClass}::operator!=(const $1 &other) const {
return !(*this == other);
}

10
c++-mode/operator+ Normal file
View File

@ -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;
}

8
c++-mode/operator+= Normal file
View File

@ -0,0 +1,8 @@
# -*- mode: snippet -*-
# name: operator+=
# key: +=
# --
${1:MyClass} & $1::operator+=(const $1 &rhs) {
$0
return *this;
}

12
c++-mode/operator= Normal file
View File

@ -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;
}

7
c++-mode/operator== Normal file
View File

@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: operator==
# key: ==
# --
bool ${1:MyClass}::operator==(const $1 &other) const {
$0
}

6
c++-mode/private Normal file
View File

@ -0,0 +1,6 @@
# -*- mode: snippet -*-
# name: private
# key: pr
# --
private:
$0

View File

@ -1,6 +1,6 @@
# -*- mode: snippet -*-
# name: protected
# key: proc
# key: pt
# --
protected:
$0

View File

@ -1,6 +1,6 @@
# -*- mode: snippet -*-
# name: public
# key: pub
# key: pb
# --
public:
$0

5
c++-mode/this Normal file
View File

@ -0,0 +1,5 @@
# -*- mode: snippet -*-
# name: this
# key: th
# --
this