vimrc/sources_non_forked/vim-snippets/snippets/cpp.snippets

206 lines
3.9 KiB
Text
Raw Normal View History

2015-07-13 10:22:46 +00:00
extends c
2015-12-08 13:20:04 +00:00
##
## Preprocessor
# #include <...>
2016-08-20 11:23:52 +00:00
snippet incc
2015-12-08 13:20:04 +00:00
#include <${1:iostream}>
snippet binc
#include <boost/${1:shared_ptr}.hpp>
##
## STL Collections
# std::array
snippet array
std::array<${1:T}, ${2:N}> ${3};
# std::vector
snippet vector
std::vector<${1:T}> ${2};
# std::deque
snippet deque
std::deque<${1:T}> ${2};
# std::forward_list
snippet flist
std::forward_list<${1:T}> ${2};
# std::list
snippet list
std::list<${1:T}> ${2};
# std::set
snippet set
std::set<${1:T}> ${2};
# std::map
snippet map
std::map<${1:Key}, ${2:T}> ${3};
# std::multiset
snippet mset
std::multiset<${1:T}> ${2};
# std::multimap
snippet mmap
std::multimap<${1:Key}, ${2:T}> ${3};
# std::unordered_set
snippet uset
std::unordered_set<${1:T}> ${2};
# std::unordered_map
snippet umap
std::unordered_map<${1:Key}, ${2:T}> ${3};
# std::unordered_multiset
snippet umset
std::unordered_multiset<${1:T}> ${2};
# std::unordered_multimap
snippet ummap
std::unordered_multimap<${1:Key}, ${2:T}> ${3};
# std::stack
snippet stack
std::stack<${1:T}> ${2};
# std::queue
snippet queue
std::queue<${1:T}> ${2};
# std::priority_queue
snippet pqueue
std::priority_queue<${1:T}> ${2};
##
## Access Modifiers
# private
snippet pri
private
# protected
snippet pro
protected
# public
snippet pub
public
# friend
snippet fr
friend
# mutable
snippet mu
mutable
2013-07-17 23:06:05 +00:00
##
## Class
# class
snippet cl
2017-04-01 11:22:06 +00:00
/*! \class $1
2017-03-07 17:04:28 +00:00
* \brief ${3:Brief class description}
2017-04-01 11:22:06 +00:00
*
* ${4:Detailed description}
2017-03-07 17:04:28 +00:00
*/
2013-07-17 23:06:05 +00:00
class ${1:`vim_snippets#Filename('$1', 'name')`}
{
public:
$1(${2});
2017-03-07 17:04:28 +00:00
virtual ~$1();
2017-03-07 17:04:28 +00:00
protected:
m_${5}; /*!< ${6:Member description} */
};
# member function implementation
snippet mfun
2013-07-17 23:06:05 +00:00
${4:void} ${1:`vim_snippets#Filename('$1', 'ClassName')`}::${2:memberFunction}(${3}) {
${0}
}
2017-03-07 17:04:28 +00:00
# member function implementation without parameters
snippet dmfun0
/*! \brief ${4:Brief function description here}
*
* ${5:Detailed description}
2017-04-01 11:22:06 +00:00
*
2017-03-07 17:04:28 +00:00
* \return ${6:Return parameter description}
*/
${3:void} ${1:`vim_snippets#Filename('$1', 'ClassName')`}::${2:memberFunction}() {
${0}
}
# member function implementation with one parameter
snippet dmfun1
/*! \brief ${6:Brief function description here}
*
* ${7:Detailed description}
2017-04-01 11:22:06 +00:00
*
2017-03-07 17:04:28 +00:00
* \param $4 ${8:Parameter description}
* \return ${9:Return parameter description}
*/
${5:void} ${1:`vim_snippets#Filename('$1', 'ClassName')`}::${2:memberFunction}(${3:Type} ${4:Parameter}) {
${0}
}
# member function implementation with two parameter
snippet dmfun2
/*! \brief ${8:Brief function description here}
*
* ${9:Detailed description}
2017-04-01 11:22:06 +00:00
*
2017-03-07 17:04:28 +00:00
* \param $4 ${10:Parameter description}
* \param $6 ${11:Parameter description}
* \return ${12:Return parameter description}
*/
${7:void} ${1:`vim_snippets#Filename('$1', 'ClassName')`}::${2:memberFunction}(${3:Type} ${4:Parameter},${5:Type} ${6:Parameter}) {
${0}
}
# namespace
snippet ns
2013-07-17 23:06:05 +00:00
namespace ${1:`vim_snippets#Filename('', 'my')`} {
${0}
} /* namespace $1 */
##
## Input/Output
# std::cout
snippet cout
std::cout << ${1} << std::endl;
# std::cin
snippet cin
std::cin >> ${1};
##
2016-05-14 11:57:54 +00:00
## Casts
# static
snippet sca
static_cast<${1:unsigned}>(${2:expr})${3}
# dynamic
snippet dca
dynamic_cast<${1:unsigned}>(${2:expr})${3}
# reinterpret
snippet rca
reinterpret_cast<${1:unsigned}>(${2:expr})${3}
# const
snippet cca
const_cast<${1:unsigned}>(${2:expr})${3}
## Iteration
2013-07-17 23:06:05 +00:00
# for i
snippet fori
for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
2013-07-17 23:06:05 +00:00
${4}
}
# foreach
snippet fore
for (${1:auto} ${2:i} : ${3:container}) {
2013-07-17 23:06:05 +00:00
${4}
}
# iterator
snippet iter
for (${1:std::vector}<${2:type}>::${3:const_iterator} ${4:i} = ${5:container}.begin(); $4 != $5.end(); ++$4) {
${6}
}
# auto iterator
snippet itera
for (auto ${1:i} = ${2:container}.begin(); $1 != $2.end(); ++$1) {
${3:std::cout << *$1 << std::endl;}
}
##
## Lambdas
# lamda (one line)
snippet ld
2016-06-11 13:56:50 +00:00
[${1}](${2}){${3}};
# lambda (multi-line)
snippet lld
[${1}](${2}){
2013-07-17 23:06:05 +00:00
${3}
2016-06-11 13:56:50 +00:00
};
2017-04-01 11:22:06 +00:00
# snippets exception
2017-03-07 17:04:28 +00:00
snippet try
try {
}catch(${1}) {
}