join.hpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*=============================================================================
  2. Copyright (c) 2012 Paul Fultz II
  3. join.h
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ==============================================================================*/
  7. #ifndef BOOST_HOF_GUARD_FUNCTION_DETAIL_JOIN_H
  8. #define BOOST_HOF_GUARD_FUNCTION_DETAIL_JOIN_H
  9. #include <boost/hof/detail/holder.hpp>
  10. namespace boost { namespace hof { namespace detail {
  11. template<class... Ts>
  12. struct join_args
  13. {};
  14. template<template <class...> class T, class Args, class=void>
  15. struct join_impl
  16. {};
  17. template<template <class...> class T, class... Args>
  18. struct join_impl<T, join_args<Args...>, typename holder<
  19. T<Args...>
  20. >::type>
  21. { typedef T<Args...> type; };
  22. template<template <class...> class T, class... Args>
  23. struct join
  24. : join_impl<T, join_args<Args...>>
  25. {};
  26. }}} // namespace boost::hof
  27. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
  28. #define BOOST_HOF_JOIN(c, ...) typename boost::hof::detail::join<c, __VA_ARGS__>::type
  29. #else
  30. #define BOOST_HOF_JOIN(c, ...) c<__VA_ARGS__>
  31. #endif
  32. #endif