include/meltpooldg/utilities/cpp23_functions.h Source File

Developer Documentation: include/meltpooldg/utilities/cpp23_functions.h Source File
Developer Documentation
cpp23_functions.h
Go to the documentation of this file.
1
5#pragma once
6
7#include <iterator>
8
10{
11 // Similar to std::ranges::contains. Enforces the container to have a begin() and end() iterator.
12 template <typename Container>
13 concept range = requires(Container &t) {
14 {
15 // Return an iterator to the first element of the container
16 t.begin()
17 } -> std::input_or_output_iterator;
18 {
19 // Return an iterator to one element behind the last element of the container
20 t.end()
21 } -> std::input_or_output_iterator;
22 };
23
24 template <range Container>
25 bool
26 contains(const Container &c, typename Container::value_type const value)
27 {
28 return (std::find(c.begin(), c.end(), value) != c.end());
29 }
30} // namespace MeltPoolDG::Utils
Definition cpp23_functions.h:13
Implementation of functions defined by C++23.
Definition cpp23_functions.h:10
bool contains(const Container &c, typename Container::value_type const value)
Definition cpp23_functions.h:26