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 <algorithm> | |
#include <iostream> | |
#include <ranges> | |
#include <vector> | |
struct Package { | |
double weight; | |
double price; | |
}; | |
using package_list_t = std::vector<Package>; |
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 <functional> | |
int main() | |
{ | |
int a{100}, b{200}; | |
std::vector<std::reference_wrapper<int>> vec{std::ref(a), std::ref(b)}; | |
a = 10; |
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 <numeric> | |
#include <array> | |
inline constexpr int fn() | |
{ | |
constexpr const std::array<int, 5> myArray = {{1, 2, 3, 4, 5}}; | |
constexpr const int sum = std::accumulate( | |
myArray.begin(), myArray.end(), 1, std::multiplies<int>()); | |
return sum; | |
} |
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 <variant> | |
#include <vector> | |
/* base class has the commmon elements */ | |
struct document { | |
void add_content(std::string &&line); | |
const std::vector<std::string> &get_content() const; | |
protected: | |
std::vector<std::string> m_content{}; |
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 <sstream> | |
#include <vector> | |
#include <string> | |
#include <memory> | |
enum class format_t | |
{ | |
markdown, | |
html, |
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 <variant> | |
#include <optional> | |
/* --------------------------------- Events ------------------------------------------ */ | |
struct event_connecting { | |
std::string m_address{}; | |
}; |
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 <memory> | |
/* --------------------------------- Events ------------------------------------------ */ | |
enum class event_t | |
{ | |
connecting, | |
connected, | |
disconnect, |
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
// Example program | |
#include <iostream> | |
#include <string> | |
#include <map> | |
#include <vector> | |
struct database { | |
virtual std::uint32_t get_population(const std::string &name) = 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 <string> | |
#include <memory> | |
#include <sstream> | |
#include <iostream> | |
struct Office { | |
std::string m_street{}; | |
std::string m_city{}; | |
std::int32_t m_cubical{}; | |