Skip to content

Instantly share code, notes, and snippets.

@playmer
Created February 16, 2019 01:43
Show Gist options
  • Save playmer/c3463db9ca6f33b77661d16c1b83a92e to your computer and use it in GitHub Desktop.
Save playmer/c3463db9ca6f33b77661d16c1b83a92e to your computer and use it in GitHub Desktop.
//Given by beached from the include<c++> discord
// "if you want to be fancy, throw in a noexcept( std::is_nothrow_invokable_v<Function> )"
template<typename Function>
constexpr void do_n( size_t count, Function func ) {
while( count-- > 0 ) {
std::invoke( func );
}
}
std::vector<int> v{}
do_n( 1000, [&v]( ) { v.emplace_back( .... ); } );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment