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 <deque> | |
#include <stack> | |
#include <mutex> | |
#include <thread> | |
#include <algorithm> | |
#include <functional> | |
#include <type_traits> | |
#include <unordered_map> | |
#include <condition_variable> |
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 <mutex> | |
#include <thread> | |
#include <iostream> | |
struct Singleton | |
{ | |
static Singleton& instance() | |
{ | |
std::lock_guard<std::mutex> lock(m); | |
static Singleton s; |
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 <initializer_list> | |
#include <type_traits> | |
#include <memory> | |
#include <iostream> | |
template <class T> | |
using ref_ptr = std::decay_t<T>*&; | |
template <class> | |
struct Node; |
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 <iterator> | |
#include <algorithm> | |
#include <initializer_list> | |
template<typename T> | |
struct LinkedList; | |
template<typename T> | |
struct node |
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> | |
#define LOG_ARG(ARG) \ | |
do { std::cout << __PRETTY_FUNCTION__ << std::endl; } while (0) | |
#define LOG LOG_ARG(__PRETTY_FUNCTION__) | |
class Widget { | |
class Toolbox { }; | |
public: |
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 <algorithm> | |
template<class T> | |
class dumb_array | |
{ | |
public: | |
dumb_array(std::size_t size = 0) noexcept(noexcept(T())) | |
: m_size(size) | |
, m_array(size ? new T[m_capacity]() : 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 <iterator> | |
class student_fmt; | |
struct student | |
{ | |
student() = default; | |
student(std::string const& name, std::string const& 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
template<class T> | |
decltype(f(T())) h() {} | |
void f(int); | |
void f(struct X); | |
struct X {}; | |
int main() | |
{ |
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
/* nth node from end */ | |
void nthNodeFromEnd(node* head, int n) | |
{ | |
int size = 0; | |
node* temp = head; | |
for (; temp; ++size, temp = temp->next) | |
{ } | |
if (size < n) | |
return; |
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 <unordered_set> | |
struct node | |
{ | |
node(int data, node* next = nullptr) | |
: data(data) | |
, next(next) | |
{ } | |