From eecf4b1e666211a13afa56f93477c55e8fd01621 Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 2 Jun 2022 19:51:54 +0200 Subject: feat: implement game of life --- src/util/concepts.hpp | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/util/concepts.hpp (limited to 'src/util/concepts.hpp') diff --git a/src/util/concepts.hpp b/src/util/concepts.hpp new file mode 100644 index 0000000..928ee39 --- /dev/null +++ b/src/util/concepts.hpp @@ -0,0 +1,78 @@ +#pragma once + +#include +#include + +/** + * Concept for the Container named requirement. + * + * https://en.cppreference.com/w/cpp/named_req/Container + */ +template +concept Container = requires(ContainerType container_a, const ContainerType container_b) +{ + typename ContainerType::value_type; + typename ContainerType::reference; + typename ContainerType::const_reference; + typename ContainerType::iterator; + typename ContainerType::const_iterator; + typename ContainerType::difference_type; + typename ContainerType::size_type; + + requires std::regular; + requires std::swappable; + requires std::destructible; + requires std:: + same_as; + requires std::same_as< + typename ContainerType::const_reference, + const typename ContainerType::value_type &>; + requires std::forward_iterator; + requires std::forward_iterator; + requires std::signed_integral; + requires std::same_as< + typename ContainerType::difference_type, + typename std::iterator_traits::difference_type>; + requires std::same_as< + typename ContainerType::difference_type, + typename std::iterator_traits< + typename ContainerType::const_iterator>::difference_type>; + requires std::convertible_to< + typename ContainerType::iterator, + typename ContainerType::const_iterator>; + + { + container_a.begin() + } -> std::same_as; + { + container_a.end() + } -> std::same_as; + { + container_b.begin() + } -> std::same_as; + { + container_b.end() + } -> std::same_as; + { + container_a.cbegin() + } -> std::same_as; + { + container_a.cend() + } -> std::same_as; + { + container_a.size() + } -> std::same_as; + { + container_a.max_size() + } -> std::same_as; + { + container_a.empty() + } -> std::same_as; +}; + +template +concept HasPushBack = + requires(ContainerType container, typename ContainerType::value_type value) +{ + container.push_back(value); +}; -- cgit v1.2.3-18-g5258