siplasplas
A library for C++ reflection and introspection
iostream.hpp
1 #ifndef SIPLASPLAS_TYPEERASURE_IOSTREAM_HPP
2 #define SIPLASPLAS_TYPEERASURE_IOSTREAM_HPP
3 
4 #include "concept.hpp"
5 
6 #include <siplasplas/utility/meta.hpp>
7 #include <ostream>
8 #include <istream>
9 
15 namespace cpp
16 {
17 
18 namespace concepts
19 {
20 
44 template<typename T, typename = void>
45 class OStreamable : public Concept<false> {};
46 
47 template<typename T>
48 class OStreamable<T, cpp::meta::void_t<decltype(std::declval<std::ostream&>() << std::declval<T>())>> :
49  public Concept<true, noexcept(std::declval<std::ostream&>() << std::declval<T>())>
50 {};
51 
74 template<typename T, typename = void>
75 class IStreamable : public Concept<false> {};
76 
77 template<typename T>
78 class IStreamable<T, cpp::meta::void_t<decltype(std::declval<std::istream&>() >> *static_cast<T*>(nullptr))>> :
79  public Concept<true, noexcept(std::declval<std::istream&>() >> *static_cast<T*>(nullptr))>
80 {};
81 
82 }
83 
84 }
85 
86 #endif // SIPLASPLAS_TYPEERASURE_IOSTREAM_HPP
Definition: canary_allocator.hpp:7
Checks whether a vaue of type T can be written to a standard stream.
Definition: iostream.hpp:45
Represents a concept.
Definition: concept.hpp:28