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 <cstddef> | |
#include <iostream> | |
#include <utility> | |
namespace mlib { | |
template <auto N> | |
constexpr auto get_nth_element(auto... args) { | |
return [&]<std::size_t... Indexes>(std::index_sequence<Indexes...>) { | |
return [](decltype((void*)Indexes)... DontCare, auto* arg, | |
auto*... DontCareEither) { return *arg; }(&args...); |
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> | |
template<auto A, auto B, auto first_, auto second_, typename to_compare> | |
struct inline_if | |
{ | |
constexpr auto operator()() | |
{ | |
if constexpr(to_compare{}.template operation<A, B>()) | |
{ | |
return first_; |
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<tector.hpp> | |
#include<iostream> | |
int main() | |
{ | |
tector<int, int, int, int> t{3, 5, 4, 1}; | |
t.remove_first(); // so now we just have the elements 5, 4, 1 | |
// Now we can call remove_first again like this: | |
t.remove_first(); // Now we have the elements 4, 1 |
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 T, typename... Ts> | |
struct Tuple | |
{ | |
T first; | |
Tuple<Ts...> second{}; | |
bool first_removed = false; | |
auto remove_first() | |
{ | |
if(first_removed == false) |