Support Class Library
A set of tools providing classes and utility
with_traits.h
Go to the documentation of this file.
1 #pragma once
2 #include <scl/macros.h>
5 #include <mutex>
7 
8 namespace scl{
9  namespace async{
14  template <class Resource>
15  struct with_traits{
22  template <class F>
23  auto operator()(Resource& resource, F&& delegate) -> META::return_t<F> {
25  }
26  };
27 
28  template<>
29  struct with_traits<std::mutex>{
30  template <class F>
31  auto operator()(std::mutex& mutex, F&& delegate) -> META::return_t<F> {
32  std::lock_guard<decltype(mutex)> _{mutex};
33  return std::forward<F>(delegate)();
34  }
35  };
36  }
37 }
Exception class used when a resource is used without specialized traits.
Global namespace of the SCL.
Definition: alias.hpp:3
auto operator()(std::mutex &mutex, F &&delegate) -> scl::tools::meta ::return_t< F >
Definition: with_traits.h:31
auto operator()(Resource &resource, F &&delegate) -> scl::tools::meta ::return_t< F >
Invoke a delegate using the wrapper.
Definition: with_traits.h:23
STL namespace.
constexpr scl::utils::Placeholder _
Definition: Placeholder.h:39
Traits for use with the scl::async::with function.
Definition: with_traits.h:15