libcruft-util/concepts/string.hpp

24 lines
651 B
C++

/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright 2022, Danny Robson <danny@nerdcruft.net>
*/
#pragma once
#include <concepts>
#include <string>
#include <string_view>
namespace cruft::concepts {
/// A type that behaves like a string. ie, a sequence of characters
template <typename T>
concept stringy =
std::same_as<T, std::string> or
std::same_as<T, std::string_view> or
std::same_as<T, char const*> or
std::same_as<T, char *>;
}