//
// memory
// ~~~~~~
// Function to obtain a function objects associated allocator.
//
// Copyright (c) 2014 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//

#ifndef EXECUTORS_EXPERIMENTAL_MEMORY_HEADER
#define EXECUTORS_EXPERIMENTAL_MEMORY_HEADER

#include <memory>
#include <experimental/bits/associated_allocator.h>

namespace std {
namespace experimental {
inline namespace concurrency_v1 {

// Trait used to obtain an object's associated allocator.

template <class _T, class _Alloc = allocator<void>>
struct associated_allocator
{
  typedef typename __associated_allocator<_T, _Alloc>::_Type type;

  static type get(const _T& __t, const _Alloc& __a = _Alloc()) noexcept
  {
    return __associated_allocator<_T, _Alloc>::_Get(__t, __a);
  }
};

template <class _T, class _Alloc = allocator<void>>
using associated_allocator_t = typename associated_allocator<_T, _Alloc>::type;

// Helper function to obtain an associated allocator.

template <class _T>
  associated_allocator_t<_T> get_associated_allocator(const _T& __t);
template <class _T, class _Alloc>
  associated_allocator_t<_T, _Alloc>
    get_associated_allocator(const _T& __t, const _Alloc& __a);

} // inline namespace concurrency_v1
} // namespace experimental
} // namespace std

#include <experimental/bits/get_associated_allocator.h>

#endif
