Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace detail {
- template<class T, class = void>
- struct has_close : std::false_type
- {
- };
- template<class T>
- struct has_close<T, boost::void_t<
- decltype(std::declval<T&>().close())>>
- : std::true_type
- {
- };
- template<class Stream>
- void
- close_stream(Stream& stream)
- {
- static_assert(has_close<Stream>::value,
- "Requirements not met: no close() and no customization point");
- stream.close();
- }
- struct close_stream_impl
- {
- template<class Stream>
- void
- operator()(Stream& stream) const
- {
- using detail::close_stream;
- close_stream(stream);
- }
- };
- } // detail
- constexpr
- detail::close_stream_impl
- close_stream{};
Add Comment
Please, Sign In to add comment