streamable meta
parent
fb17ff16c0
commit
6acbc24245
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.20)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
include(cmake/color.cmake)
|
include(cmake/color.cmake)
|
||||||
set(BLT_VERSION 0.18.16)
|
set(BLT_VERSION 0.18.17)
|
||||||
set(BLT_TEST_VERSION 0.0.1)
|
set(BLT_TEST_VERSION 0.0.1)
|
||||||
|
|
||||||
set(BLT_TARGET BLT)
|
set(BLT_TARGET BLT)
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
#include <blt/std/types.h>
|
#include <blt/std/types.h>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
namespace blt::meta
|
namespace blt::meta
|
||||||
{
|
{
|
||||||
|
@ -56,6 +58,29 @@ namespace blt::meta
|
||||||
template<typename Lambda>
|
template<typename Lambda>
|
||||||
lambda_helper(Lambda) -> lambda_helper<Lambda, decltype(&Lambda::operator())>;
|
lambda_helper(Lambda) -> lambda_helper<Lambda, decltype(&Lambda::operator())>;
|
||||||
|
|
||||||
|
// https://stackoverflow.com/questions/66397071/is-it-possible-to-check-if-overloaded-operator-for-type-or-class-exists
|
||||||
|
template<class T>
|
||||||
|
class is_streamable
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
template<typename Subs>
|
||||||
|
static auto test(int) -> decltype(std::declval<std::ostream&>() << std::declval<Subs>(), std::true_type())
|
||||||
|
{
|
||||||
|
return std::declval<std::true_type>();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename>
|
||||||
|
static auto test(...) -> std::false_type
|
||||||
|
{
|
||||||
|
return std::declval<std::false_type>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
static constexpr bool value = decltype(test<T>(0))::value;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline constexpr bool is_streamable_v = is_streamable<T>::value;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 8a889d3699b3c09ade435641fb034427f3fd12b6
|
Subproject commit d88c5e15079047777b418132ece5879e7c9aaa2b
|
Loading…
Reference in New Issue