struct graph
This commit is contained in:
25
examples/types/types.hpp
Normal file
25
examples/types/types.hpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#pragma once
|
||||
#include <concepts>
|
||||
#include <vector>
|
||||
namespace demo {
|
||||
template<class T> concept Addable = requires(T a) { a + a; };
|
||||
template<class T> concept Sized = requires(T a) { a.size(); };
|
||||
struct Base { int id; };
|
||||
struct Helper { int work() { return 1; } };
|
||||
template<Addable T>
|
||||
requires std::copyable<T> && (Addable<T> || Sized<T>)
|
||||
struct Box : Base {
|
||||
T value;
|
||||
std::vector<T> entries;
|
||||
Helper helper;
|
||||
using value_type = T;
|
||||
Box(Addable auto x) requires std::constructible_from<T, decltype(x)> : value(x) { helper.work(); }
|
||||
template<Sized U> requires requires(U u) { u.size(); }
|
||||
void set(const U& u) requires Addable<T> { helper.work(); }
|
||||
void run(std::integral auto n) { helper.work(); }
|
||||
template<class U> requires std::convertible_to<U, T>
|
||||
void assign(U u) { value = u; }
|
||||
};
|
||||
using IntBox = Box<int>;
|
||||
enum class State { idle, ready };
|
||||
}
|
||||
Reference in New Issue
Block a user