FairMQ  1.4.33
C++ Message Queuing Library and Framework
Traits.h
1 /********************************************************************************
2  * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 
9 #ifndef FAIR_MQ_SDK_TRAITS_H
10 #define FAIR_MQ_SDK_TRAITS_H
11 
12 #include <asio/associated_allocator.hpp>
13 #include <asio/associated_executor.hpp>
14 #include <type_traits>
15 
16 namespace asio::detail {
17 
19 template<typename T, typename Executor>
20 struct associated_executor_impl<T,
21  Executor,
22  std::enable_if_t<is_executor<typename T::ExecutorType>::value>>
23 {
24  using type = typename T::ExecutorType;
25 
26  static auto get(const T& obj, const Executor& /*ex = Executor()*/) noexcept -> type
27  {
28  return obj.GetExecutor();
29  }
30 };
31 
33 template<typename T, typename Allocator>
34 struct associated_allocator_impl<T,
35  Allocator,
36  std::enable_if_t<T::AllocatorType>>
37 {
38  using type = typename T::AllocatorType;
39 
40  static auto get(const T& obj, const Allocator& /*alloc = Allocator()*/) noexcept -> type
41  {
42  return obj.GetAllocator();
43  }
44 };
45 
46 } /* namespace asio::detail */
47 
48 #endif /* FAIR_MQ_SDK_TRAITS_H */

privacy