(Emacs/yasnippet)~C++ snippets have been pruned and edited

This commit is contained in:
2024-05-11 12:44:48 +05:30
parent 41e85002dc
commit 750722d463
136 changed files with 129 additions and 775 deletions

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: accumulate
# key: acm
# --
auto sum = std::accumulate(std::begin(${1:container}), std::end($1), 0);

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: accumulate w/ closure
# key: acl
# --
auto sum = std::accumulate(std::begin(${1:container}), std::end($1), 0, [](int total, $2) {
$3
});

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# name: adjacent_find
# key: ajf
# --
auto pos = std::adjacent_find(std::begin(${1:container}), std::end($1));
if (pos != std::end($1)) {
$2
}

View File

@@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# name: all_of
# key: alo
# --
if (std::all_of(std::begin(${1:container}), std::end($1), []($2) {
$3
})) {
$4
}

View File

@@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# name: any_of
# key: ano
# --
if (std::any_of(std::begin(${1:container}), std::end($1), []($2) {
$3
})) {
$4
}

View File

@@ -1,4 +0,0 @@
# -*- mode: snippet -*-
# name: assert
# --
assert($0);

View File

@@ -3,4 +3,4 @@
# key: bend # key: bend
# uuid: beginend # uuid: beginend
# -- # --
${1:v}.begin(), $1.end() ${1:a}.begin(), $1.end()

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# name: boost_require
# key: req
# uuid: req
# group: boost
# --
BOOST_REQUIRE( ${1:condition} );
$0

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# name: class
# --
class ${1:Name} {
public:
${1:$(yas/substr yas-text "[^: ]*")}();
${2:virtual ~${1:$(yas/substr yas-text "[^: ]*")}();}
};$0

View File

@@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# name: const_[]
# key: c[
# uuid: c[
# --
const ${1:Type}& operator[](${2:int index}) const
{
$0
}

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# name: constructor
# key: ct
# uuid: ct
# --
${1:Class}::$1(${2:args}) ${3: : ${4:init}} {
$0
}

View File

@@ -2,4 +2,4 @@
# name: copy # name: copy
# key: copy # key: copy
# -- # --
std::copy(std::begin(${1:container}), std::end($1), std::begin($2)); std::copy(${1:std::begin(${2:a})}, ${3:std::end($2)}, ${4:std::begin(${5:b})})

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: copy_backward
# key: cpb
# --
std::copy_backward(std::begin(${1:container}), std::end($1), std::end($1));

View File

@@ -2,7 +2,7 @@
# name: copy_if # name: copy_if
# key: copy_if # key: copy_if
# -- # --
std::copy_if(std::begin(${1:container}), std::end($1), std::begin($2), std::copy_if(std::begin(${1:a}), std::end($1), std::begin(${2:b}),
[]($3) { ${3:[](${4:auto x}) {
$4 ${5:return true;}
}); }});

View File

@@ -1,5 +1,5 @@
# -*- mode: snippet -*- # -*- mode: snippet -*-
# name: copy_n # name: copy_n
# key: cpn # key: copy_n
# -- # --
std::copy_n(std::begin(${1:container}), $2, std::end($1)); std::copy_n(std::begin(${1:a}), ${2:n}, std::begin(${3:b}));

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: copy
# key: oit
# --
std::copy(std::begin(${1:container}), std::end($1), std::ostream_iterator<$2>{
%\istd::cout, "$3"
});

View File

@@ -2,4 +2,4 @@
# name: count # name: count
# key: count # key: count
# -- # --
auto n = std::count(std::begin(${1:container}), std::end($1), $2); std::count(std::begin(${1:a}), std::end($1), ${2:b});

View File

@@ -2,6 +2,6 @@
# name: count_if # name: count_if
# key: count_if # key: count_if
# -- # --
auto n = std::count_if(std::begin(${1:container}), std::end($1), []($2) { std::count_if(std::begin(${1:a}), std::end($1), ${2:[](${3:auto x}) {
$3 ${4:return true;}
}); }});

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: cstd
# key: cstd
# uuid: cstd
# --
#include <cstdlib>

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: d+=
# key: d+=
# uuid: d+=
# --
${1:MyClass}& operator+=(${2:const $1 &});

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: d_operator<<
# key: <<
# uuid: <<
# --
friend std::ostream& operator<<(std::ostream&, const ${1:Class}&);

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: d_operator[]
# key: [
# uuid: [
# --
${1:Type}& operator[](${2:int index});

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: d_operator[]_const
# key: c[
# uuid: c[
# --
const ${1:Type}& operator[](${2:int index}) const;

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: d_operator>>
# key: >>
# --
friend std::istream& operator>>(std::istream&, const ${1:Name}&);

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: d_operator<<
# key: <<
# --
friend std::ostream& operator<<(std::ostream&, const ${1:Name}&);

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: delete
# key: delete
# uuid: dl
# --
delete ${1:pointer};

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: delete[]
# key: dla
# uuid: dla
# --
delete[] ${1:arr};

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: dynamic_casting
# key: cast
# uuid: cast
# --
check_and_cast<${1:Type} *>(${2:msg});

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: enum
# key: enum
# --
enum ${1:NAME} {$0};

View File

@@ -2,6 +2,4 @@
# name: equal # name: equal
# key: equal # key: equal
# -- # --
if (std::equal(std::begin(${1:container}), std::end($1), std::begin($2))) { std::equal(std::begin(${1:a}), std::end($1), std::begin(${2:b}))
$3
}

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: remove
# key: erm
# --
${1:container}.erase(std::remove(std::begin($1), std::end($1), $2), std::end($1));

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: generate_n
# key: erf
# --
${1:container}.erase($1.find_last_not_of(" \t\n\r") + 1);

View File

@@ -1,5 +1,5 @@
# -*- mode: snippet -*- # -*- mode: snippet -*-
# name: fill # name: fill
# key: fil # key: fill
# -- # --
std::fill(std::begin(${1:container}), std::end($1), $2); std::fill(std::begin(${1:a}), std::end($1), ${2:n});

View File

@@ -1,5 +1,5 @@
# -*- mode: snippet -*- # -*- mode: snippet -*-
# name: fill_n # name: fill_n
# key: fln # key: fill_n
# -- # --
std::fill_n(std::begin(${1:container}), $2, $3); std::fill_n(std::begin(${1:v}), ${2:a}, ${3:n});

View File

@@ -1,11 +0,0 @@
# -*- mode: snippet -*-
# name: find_if_not
# key: fin
# --
auto pos = std::find_if_not(std::begin(${1:container}), std::end($1),[]($2) {
$3
});
if (pos != std::end($1)) {
$4
}
$0

View File

@@ -1,8 +1,5 @@
# -*- mode: snippet -*- # -*- mode: snippet -*-
# name: find # name: find
# key: fnd # key: find
# -- # --
auto pos = std::find(std::begin(${1:container}), std::end($1), $2); std::find(std::begin(${1:v}), std::end$(1), ${2:a});
if (pos != std::end($1)) {
$3
}

View File

@@ -1,11 +0,0 @@
# -*- mode: snippet -*-
# name: find_end
# key: fne
# --
auto pos = std::find_std::end(
std::begin(${1:container}), std::end($1),
std::begin($2), std::end($3)
);
if (pos != std::end($1)) {
$4
}

View File

@@ -1,11 +1,8 @@
# -*- mode: snippet -*- # -*- mode: snippet -*-
# name: find_first_of # name: find_first_of
# key: ffo # key: find_first_of
# -- # --
auto pos = std::find_first_of( std::find_first_of(
std::begin(${1:container}), std::end($1), std::begin(${1:a}), std::end($1),
std::begin($2), std::end($3) std::begin(${2:b}), std::end($2)
); );
if (pos != std::end($1)) {
$4
}

View File

@@ -1,10 +1,7 @@
# -*- mode: snippet -*- # -*- mode: snippet -*-
# name: find_if # name: find_if
# key: fni # key: find_if
# -- # --
auto pos = std::find_if(std::begin(${1:container}), std::end($1), []($2) { std::find_if(std::begin(${1:v}), std::end($1), ${2:[](${3:auto x}) {
$3 ${4:return true;}
}); }});
if (pos != std::end($1)) {
$4
}

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: find_if_not
# key: find_if_not
# --
std::find_if_not(std::begin(${1:v}), std::end($1), ${2:[](${3:auto x}) {
${4:return true;}
}});

View File

@@ -1,10 +0,0 @@
# -*- mode: snippet -*-
# name: fixture
# key: fixt
# uuid: fixt
# --
BOOST_FIXTURE_TEST_SUITE( ${1:name}, ${2:Fixture} )
$0
BOOST_AUTO_TEST_SUITE_END()

View File

@@ -1,7 +1,7 @@
# -*- mode: snippet -*- # -*- mode: snippet -*-
# name: for_each # name: for_each
# key: fre # key: for_each
# -- # --
std::for_each(std::begin(${1:container}), std::end($1), []($2) { std::for_each(std::begin(${1:container}), std::end($1), ${2:[](${3:auto x}) {
$3 ${4:(void) x;}
}); }});

View File

@@ -0,0 +1,7 @@
# -*- mode: snippet -*-
# name: for_element
# key: fore
# --
for (${1:const auto &x} : ${2:u}) {
$0
}

View File

@@ -3,6 +3,6 @@
# key: fori # key: fori
# uuid: fori # uuid: fori
# -- # --
for (${1:iter}=${2:var}.begin(); $1!=$2.end(); ++$1) { for (auto ${1:iter} = std::begin(${2:var}); $1 != std::end($2); ++$1) {
$0 $0
} }

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: friend
# key: fr
# uuid: fr
# --
friend $0;

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: fun_declaration
# key: f
# uuid: f
# --
${1:void} ${2:name}($3)$0

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: function
# --
${1:void} ${2:Class}::${3:name}($4)${5: const} {
$0
}

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: generate
# key: gnr
# --
std::generate(std::begin(${1:container}), std::end($1), []($2) {
$3
});

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: generate_n
# key: gnn
# --
std::generate_n(std::begin(${1:container}), $2, []($3) {
$4
});

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: gtest
# key: gtest
# uuid: gtest
# group: testing
# --
#include <gtest/gtest.h>

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: ignore
# key: ignore
# uuid: ignore
# --
${1:std::}cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: #include <lib>
# key: inc
# --
#include <${1:lib}>

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: #include <iostream>
# key: iio
# uuid: iio
# --
#include <iostream>

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: #include <sstream>
# key: iss
# uuid: iss
# --
#include <sstream>

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: #include <string>
# key: istr
# uuid: istr
# --
#include <string>

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: inline
# key: il
# uuid: il
# --
inline $0

View File

@@ -1,5 +1,5 @@
# -*- mode: snippet -*- # -*- mode: snippet -*-
# name: iota # name: iota
# key: ita # key: iota
# -- # --
std::iota(std::begin(${1:container}), std::end($1), $2); std::iota(std::begin(${1:v}), std::end($1), ${2:n});

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: is_heap
# key: ihp
# --
if (std::is_heap(std::begin(${1:container}), std::end($1))) {
$2
}

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# name: is_heap_until
# key: ihu
# --
auto pos = std::is_heap_until(std::begin(${1:container}), std::end($1));
if (pos != std::end($1)) {
$2
}

View File

@@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# name: is_partitioned
# key: ipt
# --
if (std::is_partitioned(std::begin(${1:container}), std::end($1), []($2) {
$3
})) {
$4
}

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: is_permutation
# key: ipr
# --
if (std::is_permutation(std::begin(${1:container}), std::end($1), std::begin($2))) {
$3
}

View File

@@ -1,7 +1,5 @@
# -*- mode: snippet -*- # -*- mode: snippet -*-
# name: is_sorted # name: is_sorted
# key: iss # key: is_sorted
# -- # --
if (std::is_sorted(std::begin(${1:container}), std::end($1))) { std::is_sorted(std::begin(${1:v}), std::end($1))
$2
}

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# name: is_sorted_until
# key: isu
# --
auto pos = std::is_sorted_until(std::begin(${1:container}), std::end($1));
if (pos != std::end($1)) {
$2
}

View File

@@ -3,4 +3,4 @@
# key: iter # key: iter
# uuid: iter # uuid: iter
# -- # --
${1:std::}${2:vector<int>}::iterator ${3:iter}; ${1:std::vector<int>}::iterator ${3:iter};

View File

@@ -2,4 +2,4 @@
# name: lambda # name: lambda
# key: lam # key: lam
# -- # --
[$1]($2) { `(!%!)`$3 } [$1]($2) { $0 }

View File

@@ -1,7 +1,5 @@
# -*- mode: snippet -*- # -*- mode: snippet -*-
# name: lexigraphical_compare # name: lexigraphical_compare
# key: lxc # key: lexigraphical_compare
# -- # --
if (std::lexigraphical_compare(std::begin(${1:container}), std::end($1), std::begin($2), std::end($3))) { std::lexigraphical_compare(std::begin(${1:a}), std::end($1), std::begin(${2:b}), std::end($2))
$4
}

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: make_heap
# key: mkh
# --
std::make_heap(std::begin(${1:container}), std::end($1));

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: map
# key: map
# uuid: map
# --
std::map<${1:type1}$0> ${2:var};

View File

@@ -1,5 +1,5 @@
# -*- mode: snippet -*- # -*- mode: snippet -*-
# name: max_element # name: max_element
# key: mxe # key: max_element
# -- # --
auto pos = std::max_element(std::begin(${1:container}), std::end($1)); std::max_element(std::begin(${1:container}), std::end($1));

View File

@@ -1,8 +0,0 @@
# -*- mode: snippet -*-
# name: member_function
# key: mf
# --
${1:type} ${2:Name}::${3:name}(${4:args})${5: const}
{
$0
}

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: merge
# key: mrg
# --
std::merge(std::begin(${1:container}), std::end($1),
std::begin($2), std::end($3), std::begin($4));

View File

@@ -1,5 +1,5 @@
# -*- mode: snippet -*- # -*- mode: snippet -*-
# name: min_element # name: min_element
# key: mne # key: min_element
# -- # --
auto pos = std::min_element(std::begin(${1:container}), std::end($1)); std::min_element(std::begin(${1:container}), std::end($1));

View File

@@ -1,5 +1,5 @@
# -*- mode: snippet -*- # -*- mode: snippet -*-
# name: minmax_element # name: minmax_element
# key: mme # key: minmax_element
# -- # --
auto minmax = std::minmax_element(std::begin(${1:container}), std::end($1)); std::minmax_element(std::begin(${1:container}), std::end($1));

View File

@@ -1,10 +0,0 @@
# -*- mode: snippet -*-
# name: mismatch
# key: msm
# --
auto values = std::mismatch(std::begin(${1:container}), std::end($1), std::begin($1));
if (values.first == std::end($1)) {
$2
} else {
$3
}

View File

@@ -1,9 +0,0 @@
# -*- mode: snippet -*-
# name: module
# key: mod
# uuid: mod
# --
class ${1:Class} : public cSimpleModule
{
$0
}

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: move_backward
# key: mpb
# --
std::move_backward(std::begin(${1:container}), std::end($1), std::end($1));

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name : namespace ...
# key: ns
# uuid: ns
# --
namespace ${1:name}

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: namespace
# key: nss
# --
namespace ${1:name} {
$0
}

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: next_permutation
# key: nxp
# --
if (std::next_permutation(std::begin(${1:container}), std::end($1))) {
$2
}

View File

@@ -1,9 +1,7 @@
# -*- mode: snippet -*- # -*- mode: snippet -*-
# name: none_of # name: none_of
# key: nno # key: none_of
# -- # --
if (std::none_of(std::begin(${1:container}), std::end($1), []($2) { std::none_of(std::begin(${1:container}), std::end($1), ${2:[](${3:auto x}) {
$3 ${4:return true;}
})) { }});
$4
}

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: nth_element
# key: nth
# --
std::nth_element(std::begin(${1:container}), std::end($1), std::end($1));

View File

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

View File

@@ -1,12 +0,0 @@
# -*- mode: snippet -*-
# name: operator+
# key: +
# uuid: +
# group: operator overloading
# --
${1:MyClass} $1::operator+(const $1 &other)
{
$1 result = *this;
result += other;
return result;
}

View File

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

View File

@@ -1,14 +0,0 @@
# -*- mode: snippet -*-
# name: operator=
# key: =
# uuid: =
# where this is a reference to myself
# group: operator overloading
# --
${1:MyClass}& $1::operator=(const $1 &rhs) {
// Check for self-assignment!
if (this == &rhs)
return *this;
$0
return *this;
}

View File

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

View File

@@ -1,10 +0,0 @@
# -*- mode: snippet -*-
# name: operator[]
# key: []
# uuid: []
# group: operator overloading
# --
${1:Type}& operator[](${2:int index})
{
$0
}

View File

@@ -1,10 +1,11 @@
# -*- mode: snippet -*- # -*- mode: snippet -*-
# name: operator>> # name: operator>>
# key: >> # key: operator>>
# uuid: >> # uuid: >>
# group: operator overloading # group: operator overloading
# -- # --
istream& operator>>(istream& s, const ${1:type}& ${2:c}) istream& operator>>(istream& s, const ${1:type}& ${2:c})
{ {
$0 $0
return s;
} }

View File

@@ -1,11 +1,11 @@
# -*- mode: snippet -*- # -*- mode: snippet -*-
# name: operator<< # name: operator<<
# key: << # key: operator<<
# uuid: << # uuid: <<
# group: operator overloading # group: operator overloading
# -- # --
std::ostream& operator<<(std::ostream& s, const ${1:type}& ${2:c}) std::ostream& operator<<(std::ostream& s, const ${1:type}& ${2:c})
{ {
$0 $0
return s; return s;
} }

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: ostream
# key: os
# uuid: os
# --
#include <ostream>

View File

@@ -1,10 +0,0 @@
# -*- mode: snippet -*-
# name: pack
# key: pack
# uuid: pack
# --
void cNetCommBuffer::pack(${1:type}) {
}
$0

View File

@@ -1,5 +0,0 @@
# -*- mode: snippet -*-
# name: partial_sort
# key: pst
# --
std::partial_sort(std::begin(${1:container}), std::end($1), std::end($1));

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: partial_sort_copy
# key: psc
# --
std::partial_sort_copy(std::begin(${1:container}), std::end($1),
std::begin($2), std::end($3));

View File

@@ -1,10 +0,0 @@
# -*- mode: snippet -*-
# name: partition
# key: ptn
# --
auto pos = std::partition(std::begin(${1:container}), std::end($1), []($2) {
$3
});
if (pos != std::end($1)) {
$4
}

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: partition_copy
# key: ptc
# --
std::partition_copy(std::begin(${1:container}), std::end($1),
std::begin($2), std::end($3));

View File

@@ -1,10 +0,0 @@
# -*- mode: snippet -*-
# name: partition_point
# key: ppt
# --
auto pos = std::partition_point(std::begin(${1:container}), std::end($1), []($2) {
$3
});
if (pos != std::end($1)) {
$4
}

View File

@@ -1,7 +0,0 @@
# -*- mode: snippet -*-
# name: prev_permutation
# key: prp
# --
if (std::prev_permutation(std::begin(${1:container}), std::end($1))) {
$2
}

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: private
# expand-env: ((yas-also-auto-indent-first-line t))
# --
private:
$0

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: protected
# expand-env: ((yas-also-auto-indent-first-line t))
# --
protected:
$0

View File

@@ -1,6 +0,0 @@
# -*- mode: snippet -*-
# name: public
# expand-env: ((yas-also-auto-indent-first-line t))
# --
public:
$0

Some files were not shown because too many files have changed in this diff Show More