Skip to content

Instantly share code, notes, and snippets.

@Jiwan
Jiwan / main.cpp
Created October 30, 2015 16:13
C++11 example 1
#include <iostream>
struct A {};
std::string to_string(const A&)
{
return "I am a A!";
}
// Type B with a serialize method.
@Jiwan
Jiwan / repository_shared_ptr.cpp
Last active December 13, 2020 15:11
C++11 example for my post - An introduction to C++'s variadic templates: a thread-safe multi-type map - using shared_ptr
#include <iostream>
#include <string>
struct DefaultSlotKey;
template <class Type, class Key = DefaultSlotKey>
class Slot
{
public:
std::shared_ptr<Type> doGet() const
@Jiwan
Jiwan / main.cpp
Created October 31, 2015 19:27
C++ 14 example SFINAE!
#include <boost/hana.hpp>
#include <iostream>
#include <type_traits>
struct A {};
std::string to_string(const A&)
{
return "I am a A!";
}
@Jiwan
Jiwan / main.cpp
Created October 29, 2015 12:09
C++98 SFINAE usage for serialization
#include <iostream>
struct A {};
std::string to_string(const A&)
{
return "I am a A!";
}
// Type B with a serialize method.
#include <cassert>
#include <iostream>
#include <functional>
#include <memory>
#include <type_traits>
#include <typeinfo>
#include <typeindex>
#include <utility>
#include <unordered_map>