Skip to content

Instantly share code, notes, and snippets.

View nixiz's full-sized avatar
🎯
Focusing

Oguzhan KATLI nixiz

🎯
Focusing
View GitHub Profile
#include <iostream>
namespace dtl // detail
{
template <typename T1, typename T2 = T1>
struct carpma_t {
typedef T1 tipi;
};
template <>
@nixiz
nixiz / singleton.hpp
Last active September 17, 2021 07:11
#include <iostream>
#include <string>
#include <memory>
#include <cassert>
template <class T>
class Singleton
{
public:
using Type = typename std::remove_all_extents<T>::type;
@nixiz
nixiz / mersenne_twister_seed_finder.cpp
Last active June 18, 2019 07:42
mersenne twister algorithm seed finder for desired sequence of string.
// MersenneTwisterSeedFinder.cpp
// Copyright (c) Oguzhan KATLI. All rights reserved.
#include <random>
#include <string>
#include <iostream>
#include <thread>
#include <vector>
#include <numeric>
#include <algorithm>
#include <everything>
template <typename AnyThing>
[[ noreturn ]] void blackhole(AnyThing *obj)
{
delete obj;
}
@nixiz
nixiz / const_placement_example.cpp
Last active February 27, 2019 13:20
const placement matters
template <typename T>
void test(T p) {
(*p)++; // increment by value
p++; // increment pointer to next element
}
void testrun1()
{
int value[2] {0, 1};
test<int *>(&value[0]); // 1. compiles and runs successfuly
@nixiz
nixiz / two_singleton_dtor_problem.cpp
Last active August 14, 2018 15:49
What should happen during program shutdown if one Singleton's destructor tries to use another Singleton that's already been destroyed? The problem defined by Andrei Alexandrescu in book: Modern C++ Design: Generic Programming and Design Patterns Applied
#include <stdio.h>
/*
* Simple template singleton base class
*/
template<typename T>
class Singleton {
protected:
Singleton() = default;
Singleton(const Singleton&) = delete;