2015-07-13 06:22:46 -04:00
|
|
|
extends c
|
|
|
|
|
2022-09-20 04:08:31 -04:00
|
|
|
## Main
|
|
|
|
# main()
|
|
|
|
snippet mainn
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
${0}
|
|
|
|
return 0;
|
|
|
|
}
|
2015-12-08 08:20:04 -05:00
|
|
|
##
|
|
|
|
## Preprocessor
|
|
|
|
# #include <...>
|
2016-08-20 07:23:52 -04:00
|
|
|
snippet incc
|
2015-12-08 08:20:04 -05:00
|
|
|
#include <${1:iostream}>
|
|
|
|
snippet binc
|
|
|
|
#include <boost/${1:shared_ptr}.hpp>
|
|
|
|
##
|
2013-04-13 13:45:21 -04:00
|
|
|
## STL Collections
|
|
|
|
# std::array
|
|
|
|
snippet array
|
2013-11-16 14:45:48 -05:00
|
|
|
std::array<${1:T}, ${2:N}> ${3};
|
2013-04-13 13:45:21 -04:00
|
|
|
# std::vector
|
|
|
|
snippet vector
|
2013-11-16 14:45:48 -05:00
|
|
|
std::vector<${1:T}> ${2};
|
2013-04-13 13:45:21 -04:00
|
|
|
# std::deque
|
|
|
|
snippet deque
|
2013-11-16 14:45:48 -05:00
|
|
|
std::deque<${1:T}> ${2};
|
2013-04-13 13:45:21 -04:00
|
|
|
# std::forward_list
|
|
|
|
snippet flist
|
2013-11-16 14:45:48 -05:00
|
|
|
std::forward_list<${1:T}> ${2};
|
2013-04-13 13:45:21 -04:00
|
|
|
# std::list
|
|
|
|
snippet list
|
2013-11-16 14:45:48 -05:00
|
|
|
std::list<${1:T}> ${2};
|
2013-04-13 13:45:21 -04:00
|
|
|
# std::set
|
|
|
|
snippet set
|
2013-11-16 14:45:48 -05:00
|
|
|
std::set<${1:T}> ${2};
|
2013-04-13 13:45:21 -04:00
|
|
|
# std::map
|
|
|
|
snippet map
|
2013-11-16 14:45:48 -05:00
|
|
|
std::map<${1:Key}, ${2:T}> ${3};
|
2013-04-13 13:45:21 -04:00
|
|
|
# std::multiset
|
|
|
|
snippet mset
|
2013-11-16 14:45:48 -05:00
|
|
|
std::multiset<${1:T}> ${2};
|
2013-04-13 13:45:21 -04:00
|
|
|
# std::multimap
|
|
|
|
snippet mmap
|
2013-11-16 14:45:48 -05:00
|
|
|
std::multimap<${1:Key}, ${2:T}> ${3};
|
2013-04-13 13:45:21 -04:00
|
|
|
# std::unordered_set
|
|
|
|
snippet uset
|
2013-11-16 14:45:48 -05:00
|
|
|
std::unordered_set<${1:T}> ${2};
|
2013-04-13 13:45:21 -04:00
|
|
|
# std::unordered_map
|
|
|
|
snippet umap
|
2013-11-16 14:45:48 -05:00
|
|
|
std::unordered_map<${1:Key}, ${2:T}> ${3};
|
2013-04-13 13:45:21 -04:00
|
|
|
# std::unordered_multiset
|
|
|
|
snippet umset
|
2013-11-16 14:45:48 -05:00
|
|
|
std::unordered_multiset<${1:T}> ${2};
|
2013-04-13 13:45:21 -04:00
|
|
|
# std::unordered_multimap
|
|
|
|
snippet ummap
|
2013-11-16 14:45:48 -05:00
|
|
|
std::unordered_multimap<${1:Key}, ${2:T}> ${3};
|
2013-04-13 13:45:21 -04:00
|
|
|
# std::stack
|
|
|
|
snippet stack
|
2013-11-16 14:45:48 -05:00
|
|
|
std::stack<${1:T}> ${2};
|
2013-04-13 13:45:21 -04:00
|
|
|
# std::queue
|
|
|
|
snippet queue
|
2013-11-16 14:45:48 -05:00
|
|
|
std::queue<${1:T}> ${2};
|
2013-04-13 13:45:21 -04:00
|
|
|
# std::priority_queue
|
|
|
|
snippet pqueue
|
2013-11-16 14:45:48 -05:00
|
|
|
std::priority_queue<${1:T}> ${2};
|
2013-04-13 13:45:21 -04:00
|
|
|
##
|
2018-09-24 20:40:17 -04:00
|
|
|
## STL smart pointers
|
|
|
|
# std::shared_ptr
|
|
|
|
snippet msp
|
|
|
|
std::shared_ptr<${1:T}> ${2} = std::make_shared<$1>(${3});
|
2019-08-22 11:36:17 -04:00
|
|
|
snippet amsp
|
|
|
|
auto ${1} = std::make_shared<${2:T}>(${3});
|
2018-09-24 20:40:17 -04:00
|
|
|
# std::unique_ptr
|
|
|
|
snippet mup
|
|
|
|
std::unique_ptr<${1:T}> ${2} = std::make_unique<$1>(${3});
|
2019-08-22 11:36:17 -04:00
|
|
|
snippet amup
|
|
|
|
auto ${1} = std::make_unique<${2:T}>(${3});
|
2018-09-24 20:40:17 -04:00
|
|
|
##
|
2013-04-13 13:45:21 -04:00
|
|
|
## 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 19:06:05 -04:00
|
|
|
##
|
2013-04-13 13:45:21 -04:00
|
|
|
## Class
|
|
|
|
# class
|
|
|
|
snippet cl
|
2017-04-01 07:22:06 -04:00
|
|
|
/*! \class $1
|
2017-03-07 12:04:28 -05:00
|
|
|
* \brief ${3:Brief class description}
|
2017-04-01 07:22:06 -04:00
|
|
|
*
|
|
|
|
* ${4:Detailed description}
|
2017-03-07 12:04:28 -05:00
|
|
|
*/
|
2013-07-17 19:06:05 -04:00
|
|
|
class ${1:`vim_snippets#Filename('$1', 'name')`}
|
2013-04-13 13:45:21 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
$1(${2});
|
2017-03-07 12:04:28 -05:00
|
|
|
virtual ~$1();
|
2013-04-13 13:45:21 -04:00
|
|
|
|
2017-03-07 12:04:28 -05:00
|
|
|
protected:
|
|
|
|
m_${5}; /*!< ${6:Member description} */
|
2013-04-13 13:45:21 -04:00
|
|
|
};
|
|
|
|
# member function implementation
|
|
|
|
snippet mfun
|
2013-07-17 19:06:05 -04:00
|
|
|
${4:void} ${1:`vim_snippets#Filename('$1', 'ClassName')`}::${2:memberFunction}(${3}) {
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-04-13 13:45:21 -04:00
|
|
|
}
|
2017-03-07 12:04:28 -05:00
|
|
|
# member function implementation without parameters
|
|
|
|
snippet dmfun0
|
|
|
|
/*! \brief ${4:Brief function description here}
|
|
|
|
*
|
|
|
|
* ${5:Detailed description}
|
2017-04-01 07:22:06 -04:00
|
|
|
*
|
2017-03-07 12:04:28 -05: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 07:22:06 -04:00
|
|
|
*
|
2017-03-07 12:04:28 -05: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 07:22:06 -04:00
|
|
|
*
|
2017-03-07 12:04:28 -05: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}
|
|
|
|
}
|
2013-04-13 13:45:21 -04:00
|
|
|
# namespace
|
|
|
|
snippet ns
|
2013-07-17 19:06:05 -04:00
|
|
|
namespace ${1:`vim_snippets#Filename('', 'my')`} {
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-04-13 13:45:21 -04:00
|
|
|
} /* namespace $1 */
|
2018-02-04 06:35:08 -05:00
|
|
|
snippet ans
|
|
|
|
namespace {
|
|
|
|
${0}
|
|
|
|
}
|
2013-04-13 13:45:21 -04:00
|
|
|
##
|
|
|
|
## Input/Output
|
|
|
|
# std::cout
|
|
|
|
snippet cout
|
2013-11-16 14:45:48 -05:00
|
|
|
std::cout << ${1} << std::endl;
|
2013-04-13 13:45:21 -04:00
|
|
|
# std::cin
|
|
|
|
snippet cin
|
2013-11-16 14:45:48 -05:00
|
|
|
std::cin >> ${1};
|
2013-04-13 13:45:21 -04:00
|
|
|
##
|
2016-05-14 07:57:54 -04: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}
|
2013-04-13 13:45:21 -04:00
|
|
|
## Iteration
|
2013-07-17 19:06:05 -04:00
|
|
|
# for i
|
2013-04-13 13:45:21 -04:00
|
|
|
snippet fori
|
|
|
|
for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
|
2013-07-17 19:06:05 -04:00
|
|
|
${4}
|
2013-11-16 14:45:48 -05:00
|
|
|
}
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
# foreach
|
|
|
|
snippet fore
|
|
|
|
for (${1:auto} ${2:i} : ${3:container}) {
|
2013-07-17 19:06:05 -04:00
|
|
|
${4}
|
2013-11-16 14:45:48 -05:00
|
|
|
}
|
2013-04-13 13:45:21 -04:00
|
|
|
# iterator
|
|
|
|
snippet iter
|
|
|
|
for (${1:std::vector}<${2:type}>::${3:const_iterator} ${4:i} = ${5:container}.begin(); $4 != $5.end(); ++$4) {
|
|
|
|
${6}
|
2013-11-16 14:45:48 -05:00
|
|
|
}
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
# auto iterator
|
|
|
|
snippet itera
|
2013-11-16 14:45:48 -05:00
|
|
|
for (auto ${1:i} = ${2:container}.begin(); $1 != $2.end(); ++$1) {
|
|
|
|
${3:std::cout << *$1 << std::endl;}
|
|
|
|
}
|
2013-04-13 13:45:21 -04:00
|
|
|
##
|
|
|
|
## Lambdas
|
|
|
|
# lamda (one line)
|
|
|
|
snippet ld
|
2016-06-11 09:56:50 -04:00
|
|
|
[${1}](${2}){${3}};
|
2013-04-13 13:45:21 -04:00
|
|
|
# lambda (multi-line)
|
|
|
|
snippet lld
|
|
|
|
[${1}](${2}){
|
2013-07-17 19:06:05 -04:00
|
|
|
${3}
|
2016-06-11 09:56:50 -04:00
|
|
|
};
|
2017-04-01 07:22:06 -04:00
|
|
|
# snippets exception
|
2017-03-07 12:04:28 -05:00
|
|
|
snippet try
|
|
|
|
try {
|
|
|
|
|
2018-03-31 10:56:26 -04:00
|
|
|
}catch(${1}) {
|
2017-03-07 12:04:28 -05:00
|
|
|
|
2018-03-31 10:56:26 -04:00
|
|
|
}
|
2021-10-28 15:48:21 -04:00
|
|
|
# auto function
|
2018-03-31 10:56:26 -04:00
|
|
|
snippet af auto function
|
|
|
|
auto ${1:name}(${2}) -> ${3:void}
|
|
|
|
{
|
|
|
|
${0}
|
|
|
|
};
|
2023-07-15 06:43:27 -04:00
|
|
|
# Range-v3 transform
|
|
|
|
snippet transform "ranges::views::transform"
|
|
|
|
${1:${2:std::}${3:ranges::}views::}transform($4)
|
|
|
|
# Range-v3 transform
|
|
|
|
snippet filter "ranges::views::filter"
|
|
|
|
${1:${2:std::}${3:ranges::}views::}filter($4)
|
|
|
|
# Range-v3 ranges::
|
|
|
|
snippet r "ranges::"
|
|
|
|
ranges::
|
|
|
|
# Range-v3 ranges::views::
|
|
|
|
snippet rv "ranges::views::"
|
|
|
|
ranges::views::
|
|
|
|
# Range-v3 ranges::actions::
|
|
|
|
snippet ra "ranges::actions::"
|
|
|
|
ranges::actions::
|
|
|
|
# STL std::ranges::
|
|
|
|
snippet sr "std::ranges::"
|
|
|
|
std::ranges::
|
|
|
|
# STL std::views::
|
|
|
|
snippet sv "std::views::"
|
|
|
|
std::views::
|
2024-01-07 10:14:20 -05:00
|
|
|
##
|
|
|
|
## Tests
|
|
|
|
# GTest:add main
|
|
|
|
snippet gtemain "GTest:add main"
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
testing::InitGoogleTest(&argc, argv);
|
|
|
|
return RUN_ALL_TESTS();
|
|
|
|
}
|
|
|
|
# GTest:add test
|
|
|
|
snippet gtetest "GTest:add test"
|
|
|
|
TEST(${1:SuiteName}, ${2:TestName}) {
|
|
|
|
${0}
|
|
|
|
}
|
|
|
|
# GTest:add fixture
|
|
|
|
snippet gtefix "GTest:add fixture"
|
|
|
|
TEST_F(${1:SuiteName}, ${2:TestName}) {
|
|
|
|
${0}
|
|
|
|
}
|
|
|
|
# GTest:add parameterized test
|
|
|
|
snippet gtepar "GTest:add parameterized test"
|
|
|
|
TEST_P(${1:SuiteName}, ${2:TestName}) {
|
|
|
|
${0}
|
|
|
|
}
|
|
|
|
# GTest:instantiate parameterized test
|
|
|
|
snippet gteparins "GTest:instantiate parameterized test"
|
|
|
|
INSTANTIATE_TEST_SUITE_P(${1:InstantiationName}, ${2:SuiteName}, ${0});
|