I have piece of sample code (copied from stack overflow)
//some lines of code
template <typename ... Args>
std::string string_format (
const std::string& format,
Args ... args )
{
int size_s = std::snprintf( nullptr, 0, format.c_str(), args ... ) + 1;
if( size_s <= 0 ){ throw std::runtime_error( "Error during formatting." ); }
auto size = static_cast<size_t>( size_s );
std::unique_ptr<char[]> buf( new char[ size ] );
std::snprintf( buf.get(), size, format.c_str(), args ... );
return std::string( buf.get(), buf.get() + size - 1 );
}
For some reason, the line containing "template" is always indented.
How to stop this behavior?
I can see some relevant settings as follows: I can reproduce the problem with autoindent
, cindent
, nosmartindent
, and indentexpr=
.
Update The problem is solved by using:
set cinoptions=t0
Thank Vivian De Smedt for the solution.