bwidgets/inc/basic_widgets/core/type/concepts.hpp

33 lines
707 B
C++
Raw Normal View History

#ifndef BWIDGETS_CONCEPTS_HPP
#define BWIDGETS_CONCEPTS_HPP
#include <string>
#include <type_traits>
2021-08-06 14:22:56 +02:00
namespace bwidgets
{
2021-08-23 23:50:14 +02:00
// T can be converted to string with to_string.
template<typename T>
concept CanToString = requires(T value)
{
std::to_string(value);
};
2021-08-23 23:50:14 +02:00
// T is a floating point type.
2021-08-06 14:22:56 +02:00
template<typename T>
concept FloatingPoint = std::is_floating_point_v<T>;
2021-08-23 23:50:14 +02:00
// T can be any numeric type.
template<typename T>
concept Numeric = std::is_arithmetic_v<T>;
2021-08-23 23:50:14 +02:00
// T can be converted to string by using ostream.
template<typename T>
concept Printable = requires(T value)
{
std::declval<std::ostream&>() << value;
};
}
#endif