Currently, I am learning C++ and decided just start with C++20. However, these codes are driving me crazy, since I don't think the result makes any sense.
The following code will have the sentence Valid array. printed. What I meant above is that this is not right. It shouldn't print the sentence at all, since the type I inserted in the parameter doesn't match the concept.
Tested on VS2022 Preview 3 and an online compiler with newest GCC and C++2A(GNU) arguments, generated the same results.
#include <array>
#include <cstdio>
#include <iostream>
#include <type_traits>
using namespace std;
template<typename A> concept ProperArray = requires(A array)
{
{array.max_size() >= 2U};
{std::is_arithmetic_v<typename A::value_type> == true};
};
int main()
{
constexpr bool b = ProperArray<array<std::string, 1>>;
if constexpr (b)
cout << "Valid array." << endl;
std::cout << "Hello, Wandbox!" << std::endl;
}