This file contains 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 <stdexcept> | |
#include <utility> | |
// Исключение этого типа должно генерироватся при обращении к пустому optional | |
class BadOptionalAccess : public std::exception { | |
public: | |
using exception::exception; | |
virtual const char* what() const noexcept override { | |
return "Bad optional access"; |
This file contains 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 <cassert> | |
#include <iostream> | |
#include <memory> | |
using namespace std; | |
template <typename T> | |
struct TreeNode; |
This file contains 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 "single-linked-list.h" | |
#include <cstdalign> | |
void Test0() { | |
using namespace std; | |
{ | |
const SingleLinkedList<int> empty_int_list; | |
assert(empty_int_list.GetSize() == 0u); | |
assert(empty_int_list.IsEmpty()); | |
} |
This file contains 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 <algorithm> | |
#include <numeric> | |
#include <map> | |
using namespace std; | |
template <typename It> | |
void PrintRange(It range_begin, It range_end) { |
This file contains 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 <stdexcept> | |
#include <vector> | |
using namespace std; | |
class Tower { | |
public: | |
// конструктор и метод SetDisks нужны, чтобы правильно создать башни | |
Tower(int disks_num) { |
This file contains 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 <numeric> | |
#include <stdexcept> | |
using namespace std; | |
class Rational { | |
public: | |
Rational() = default; |
This file contains 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 <cassert> | |
#include <filesystem> | |
#include <fstream> | |
#include <iostream> | |
#include <regex> | |
#include <sstream> | |
#include <string> | |
#include <string_view> | |
#include <vector> |
This file contains 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 <typename... Ts> | |
auto Product(const Ts&... vs) { | |
return (... * vs); // (((vn1 * vn2) * ...) * vnN) | |
} | |
template <typename... Tn> | |
auto Sum(const Tn&... vn) { | |
return (... + vn); // (((vn1 + vn2) + ...) + vnN) | |
} |
This file contains 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
// Checks if there is an argument equal to the first | |
template<typename T, typename ...Tail> | |
bool EqualsToOneOf(const T &t, const Tail&... tail){ | |
if constexpr (sizeof...(tail) == 0) { | |
return false; | |
}else { | |
return ( (t == tail) || ...); | |
} | |
} |
This file contains 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
// The "ApplyToMany" template applies the function f (the first argument) sequentially to each of its other arguments | |
template <typename Function, typename ...Args> | |
void ApplyToMany(Function& f, Args&& ...args) { | |
((f(std::forward<Args>(args))),...); | |
} |
NewerOlder