Skip to content

Instantly share code, notes, and snippets.

@Const-me
Created February 3, 2024 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Const-me/2cf6dbfd93edd607a2d9a54d2c0c3304 to your computer and use it in GitHub Desktop.
Save Const-me/2cf6dbfd93edd607a2d9a54d2c0c3304 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <vector>
#include <set>
static bool s_log = false;
void message( const char* what )
{
if( s_log )
{
printf( "%s\n", what );
}
}
struct Something
{
Something() { message( "default ctor" ); }
Something( const Something& ) { message( "copy ctor" ); }
Something( Something&& ) noexcept { message( "move ctor" ); }
bool operator==( const Something& that ) const
{
return this == &that;
}
bool operator<( const Something& that ) const
{
return this < &that;
}
};
int main()
{
std::set<Something> set;
set.insert( Something{} );
s_log = true;
std::vector<Something> vec(
std::make_move_iterator( set.begin() ),
std::make_move_iterator( set.end() ) );
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment