Do yourself a favor and login as root to save yourself some time and headaches:
$ sudo su -
Install unattended-upgrades:
#include <string_view> | |
#include <iostream> | |
template<typename T> | |
constexpr std::string_view type_name() | |
{ | |
constexpr const char prefix[] = "[with T = "; | |
constexpr std::string_view p = __PRETTY_FUNCTION__; | |
constexpr auto name_start = p.find(prefix) + sizeof(prefix) - 1; | |
constexpr auto name_end = p.find(';', name_start); |
#include <string_view> | |
#include <ctre.hpp> | |
#include <cstdio> | |
#include <cstdint> | |
#include <vector> | |
namespace adv | |
{ | |
template<class T> | |
constexpr std::string_view type_name() |
// from https://www.fluentcpp.com/2021/04/30/how-to-implement-stdconjunction-and-stddisjunction-in-c11/ | |
std::conjunction<Bs...>::value // is true if all Bs... are true, false otherwise | |
std::disjunction<Bs...>::value // is true if at least one of Bs... is true, false otherwise | |
// recursive | |
template<class...> struct conjunction : std::true_type { }; | |
template<class B1> struct conjunction<B1> : B1 { }; |
// the C function is not marked noexcept, but you know it won't throw | |
// from https://twitter.com/hankadusikova/status/1276828584179642368 | |
// technically UB | |
extern "C" int foo(); | |
template <typename Fnc> struct noexcept_cast_helper; | |
template <typename Ret, typename... Args> struct noexcept_cast_helper<Ret(*)(Args...)> { | |
using type = Ret(*)(Args...) noexcept; | |
}; |
// https://quuxplusone.github.io/blog/2020/09/29/oop-visit/ | |
#include <typeinfo> | |
#include <type_traits> | |
namespace my { | |
template<class T, class U> struct match_cvref { using type = U; }; | |
template<class T, class U> struct match_cvref<T&, U> { using type = U&; }; | |
template<class T, class U> struct match_cvref<T&&, U> { using type = U&&; }; | |
template<class T, class U> struct match_cvref<const T, U> { using type = const U; }; |
// from https://pdimov.github.io/blog/2020/09/07/named-parameters-in-c20/ | |
#include <memory> | |
#include <cstddef> | |
template<class T, class A = std::allocator<T>> class vector | |
{ | |
private: | |
struct params |
// see http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0644r1.html | |
// C++14 | |
template <class X, class Y> | |
decltype(auto) foo(X&& x, Y&& y) { | |
return std::forward<X>(x)(std::forward<Y>(y)); | |
} | |
// C++14 (?) |
// from https://blog.tartanllama.xyz/passing-overload-sets/ | |
int foo (int); | |
float foo (float); | |
// Solution 1 | |
#define FWD(...) std::forward<decltype(__VA_ARGS__)>(__VA_ARGS__) | |
#define LIFT(X) [](auto &&... args) \ |
// from: https://quuxplusone.github.io/blog/2018/08/22/puts-pretty-function/ | |
#include <stdio.h> | |
template<class T> | |
void f() { | |
#ifdef _MSC_VER | |
puts(__FUNCSIG__); | |
#else | |
puts(__PRETTY_FUNCTION__); |