115 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			115 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
extends c
 | 
						|
 | 
						|
priority 1
 | 
						|
 | 
						|
snippet enum "Enumeration"
 | 
						|
enum ${1:name} {
 | 
						|
	$0
 | 
						|
};
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet for "For loop, index or range"
 | 
						|
for (${1:auto} ${2:index} ${4/(.*;.*)|(\w*)/(?1:=:\:)/} ${4:${3:0}; $2 < ${5:count}; $2${6:++}}) {
 | 
						|
	$0
 | 
						|
}
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet struct "Structure"
 | 
						|
struct ${1:name} {
 | 
						|
	$0
 | 
						|
};
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet class "Class"
 | 
						|
class ${1:name} {
 | 
						|
 public:
 | 
						|
	${1/(\w+)\s.*/$1/}();
 | 
						|
 | 
						|
	~${1/(\w+)\s.*/$1/}();
 | 
						|
 | 
						|
	$0
 | 
						|
};
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet template "Template"
 | 
						|
template <class ${1:T}$2>$0
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet namespace "Named or anonymous namespace"
 | 
						|
namespace $1${1/(\w+)/ /}{
 | 
						|
$0
 | 
						|
}  // namespace${1/(\w*)/(?1: $1:)/}
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet const_cast "Const cast" i
 | 
						|
const_cast<$1>($2)$0
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet dynamic_cast "Dynamic cast" i
 | 
						|
dynamic_cast<$1>($2)$0
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet static_cast "Static cast" i
 | 
						|
static_cast<$1>($2)$0
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet reinterpret_cast "Reinterpret case" i
 | 
						|
reinterpret_cast<$1>($2)$0
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet [] "Labmda function" i
 | 
						|
[$1]($2)${3/(.*)/(?1: -> ::)/}$3 {$0}
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet static_assert "Static assert"
 | 
						|
static_assert($1${2:, "$3"});
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet decltype "decltype" i
 | 
						|
decltype($1)$0
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet declval "declval" i
 | 
						|
declval<$1>()$0
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet noisy "A noise class"
 | 
						|
class noisy_t {
 | 
						|
 public:
 | 
						|
	noisy_t() { puts(__PRETTY_FUNCTION__); }
 | 
						|
	noisy_t(const noisy_t &) { puts(__PRETTY_FUNCTION__); }
 | 
						|
	noisy_t(noisy_t &&) { puts(__PRETTY_FUNCTION__); }
 | 
						|
	noisy_t &operator=(const noisy_t &) { puts(__PRETTY_FUNCTION__); return *this; }
 | 
						|
	noisy_t &operator=(noisy_t &&) { puts(__PRETTY_FUNCTION__); return *this; }
 | 
						|
	~noisy_t() { puts(__PRETTY_FUNCTION__); }
 | 
						|
};
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet std::enable_if "Enable if"
 | 
						|
typename std::enable_if<${1:condition}${2:, ${3:type}}>::type
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet std::fprintf "std::fprintf ..."
 | 
						|
std::fprintf(${1:stderr}, "${2:%s}\n"${2/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$3${2/([^%]|%%)*(%.)?.*/(?2:\);)/}
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet std::printf "std::printf ..."
 | 
						|
std::printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/}
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet printf_sv "printf for std::string_view"
 | 
						|
printf("$1: %.*s\n", static_cast<int>(${1:view}.size()), $1.data());$0
 | 
						|
endsnippet
 | 
						|
 | 
						|
snippet externc "extern C block"
 | 
						|
#ifdef __cplusplus
 | 
						|
extern "C" {
 | 
						|
#endif
 | 
						|
 | 
						|
$0
 | 
						|
 | 
						|
#ifdef __cplusplus
 | 
						|
}
 | 
						|
#endif
 | 
						|
endsnippet
 |