pair_tie.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  3. Copyright (c) 2006 Dan Marsden
  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. #if !defined (BOOST_FUSION_PAIR_TIE_20060812_2058)
  8. #define BOOST_FUSION_PAIR_TIE_20060812_2058
  9. #include <boost/fusion/support/config.hpp>
  10. #include <boost/type_traits/is_const.hpp>
  11. #include <boost/utility/enable_if.hpp>
  12. namespace boost { namespace fusion {
  13. template<typename Key, typename T>
  14. struct pair;
  15. namespace result_of
  16. {
  17. template<typename Key, typename T>
  18. struct pair_tie
  19. {
  20. typedef fusion::pair<Key, T&> type;
  21. };
  22. }
  23. template<typename Key, typename T>
  24. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  25. typename disable_if<is_const<T>, typename result_of::pair_tie<Key, T>::type>::type
  26. pair_tie(T& t)
  27. {
  28. return typename result_of::pair_tie<Key, T>::type(t);
  29. }
  30. template<typename Key, typename T>
  31. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  32. typename result_of::pair_tie<Key, T const>::type
  33. pair_tie(T const& t)
  34. {
  35. return typename result_of::pair_tie<Key, T const>::type(t);
  36. }
  37. }}
  38. #endif