This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <mutex> | |
struct Object | |
{ | |
Object(int id) : id(id) | |
{ | |
std::cout << '[' << id << "] constructor" << std::endl; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <mutex> | |
#include <functional> | |
struct Object | |
{ | |
Object(int n) : n(n) {} | |
void init() { std::call_once(initialized, [this] { std::cout << "init with n=" << n << std::endl; }); } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <exception> | |
#include <cstdlib> | |
void f() noexcept(false) | |
{ | |
std::cout << "f()" << std::endl; | |
throw('F'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
template <unsigned int N> | |
struct factorial | |
{ | |
enum { value = N * factorial<N - 1>::value }; | |
}; | |
template <> | |
struct factorial<0> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <type_traits> | |
#include <typeinfo> | |
template <typename BASE, typename ... BASES> | |
struct MultiDerived : BASE, MultiDerived<BASES> ... | |
{ | |
void EveryAction() | |
{ | |
BASE::Action(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <memory> | |
#include <list> | |
struct Heavy | |
{ | |
char buffer[1024 * 1024 * 8]; | |
}; | |
std::list<std::weak_ptr<Heavy>> container; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <mutex> | |
#include <functional> | |
class Price | |
{ | |
std::uint64_t value; | |
std::ratio<1, 100> value; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
struct Object | |
{ | |
typedef int type; | |
static void action() | |
{ | |
std::cout << "Object::action()" << std::endl; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
struct A | |
{ | |
}; | |
struct B : A | |
{ | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
struct X | |
{ | |
protected: | |
int i; | |
}; | |
struct A : X | |
{ |