Created
September 5, 2020 16:44
-
-
Save metab0t/07589255d730078f1a28e0aa58a7bba8 to your computer and use it in GitHub Desktop.
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 <concepts> | |
template <typename T> concept CPLEXArrayLite = requires(T o) | |
{ | |
{ | |
o.getEnv() | |
} | |
->std::same_as<int>; | |
{ | |
o.getSize() | |
} | |
->std::convertible_to<int>; | |
o[std::declval<int>()]; | |
}; | |
template <typename T> | |
concept Array = requires(T a) | |
{ | |
typename T::value_type; | |
{a.operator[](std::declval<int>())} | |
-> std::convertible_to<typename T::value_type>; | |
{a.size()} | |
-> std::convertible_to<std::size_t>; | |
}; | |
#include <vector> | |
#include <array> | |
static_assert(Array<std::vector<int>>); | |
static_assert(Array<std::array<int, 10>>); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment