2021-07-18 18:26:12 +02:00
|
|
|
#ifndef BWIDGETS_CONCEPTS_HPP_
|
|
|
|
#define BWIDGETS_CONCEPTS_HPP_
|
|
|
|
|
2021-07-20 15:20:46 +02:00
|
|
|
#include <ostream>
|
|
|
|
#include <string>
|
2021-07-29 16:06:03 +02:00
|
|
|
|
2021-07-18 18:26:12 +02:00
|
|
|
#include <type_traits>
|
|
|
|
|
2021-08-06 14:22:56 +02:00
|
|
|
namespace bwidgets
|
2021-07-18 18:26:12 +02:00
|
|
|
{
|
2021-07-20 15:20:46 +02:00
|
|
|
template<typename T>
|
2021-07-29 16:06:03 +02:00
|
|
|
concept CanToString = requires(T value)
|
|
|
|
{
|
|
|
|
std::to_string(value);
|
|
|
|
};
|
2021-07-20 15:20:46 +02:00
|
|
|
|
2021-08-06 14:22:56 +02:00
|
|
|
template<typename T>
|
|
|
|
concept FloatingPoint = std::is_floating_point_v<T>;
|
|
|
|
|
2021-07-18 18:26:12 +02:00
|
|
|
template<typename T>
|
|
|
|
concept Numeric = std::is_arithmetic_v<T>;
|
2021-07-20 15:20:46 +02:00
|
|
|
|
|
|
|
template<typename T>
|
2021-07-29 16:06:03 +02:00
|
|
|
concept Printable = requires(T value)
|
|
|
|
{
|
|
|
|
std::declval<std::ostream&>() << value;
|
|
|
|
};
|
2021-07-18 18:26:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|