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 <vector> | |
#include <stdexcept> | |
#include <format> | |
template <typename Type> | |
struct Mat_2D{ | |
using index_t = unsigned long; | |
Mat_2D(const index_t row, |
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 <cassert> | |
template <typename T> | |
struct counter { | |
counter() { update_counter(); } | |
counter(counter&) { update_counter(); } | |
counter(counter&&) = default; | |
counter& operator=(counter&) { update_counter(); } | |
counter& operator=(counter&&) = default; |
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
// Covarience to copy derived classes with raw pointers. | |
#include <iostream> | |
#include <cassert> | |
class Base { | |
public: | |
explicit Base(const int value) : m_value(value) {} | |
// can not have copy constructor or assignment | |
// with polymorphic classes. | |
Base(Base&) = delete; |
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 <vector> | |
#include <memory> | |
#include <mutex> | |
#include <thread> | |
#include <cassert> | |
template<typename Type> | |
struct monitor { | |
template<typename ...Args> | |
monitor(Args&&... args) : |
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 base { | |
base (int a) { std::cout << "base constructor : " << a << std::endl; } | |
virtual ~base() = default; | |
}; | |
struct derived : base { | |
// inheriting constructors | |
using base::base; |
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
// pass key idom. | |
#include <iostream> | |
#include <unordered_map> | |
struct citizen { | |
private: | |
struct access_to_social_security; | |
public: | |
explicit citizen(const std::string name, |
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 <cassert> | |
// finite state machine where we statically checked. | |
// A -> [D], | |
// B -> [D, E] | |
// C -> [E] | |
struct [[nodiscard]] consume_t { | |
consume_t() = default; |
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 <thread> | |
struct [[nodiscard]] binary_spin_lock_t | |
{ | |
explicit binary_spin_lock_t(int pid_); | |
void lock(const binary_spin_lock_t &other); | |
void unlock(); | |
private: | |
int pid{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 <vector> | |
#include <cassert> | |
namespace lib { | |
template<typename iterator_t, typename data_t = iterator_t::type_trait::value> | |
iterator_t binary_search(iterator_t begin, iterator_t end, const data_t &data); | |
} | |
template<typename iterator_t, typename data_t = iterator_t::type_trait::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> | |
#include <string_view> | |
#include <fmt/core.h> | |
#include <experimental/source_location> | |
#include <stdexcept> | |
#include <memory> | |
template <typename ...Args> | |
struct LOG | |
{ |
NewerOlder