promotes_arg.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* Copyright 2003-2017 Joaquin M Lopez Munoz.
  2. * Distributed under the Boost Software License, Version 1.0.
  3. * (See accompanying file LICENSE_1_0.txt or copy at
  4. * http://www.boost.org/LICENSE_1_0.txt)
  5. *
  6. * See http://www.boost.org/libs/multi_index for library home page.
  7. */
  8. #ifndef BOOST_MULTI_INDEX_DETAIL_PROMOTES_ARG_HPP
  9. #define BOOST_MULTI_INDEX_DETAIL_PROMOTES_ARG_HPP
  10. #if defined(_MSC_VER)
  11. #pragma once
  12. #endif
  13. #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
  14. #include <boost/detail/workaround.hpp>
  15. /* Metafunctions to check if f(arg1,arg2) promotes either arg1 to the type of
  16. * arg2 or viceversa. By default, (i.e. if it cannot be determined), no
  17. * promotion is assumed.
  18. */
  19. #if BOOST_WORKAROUND(BOOST_MSVC,<1400)
  20. namespace boost{
  21. namespace multi_index{
  22. namespace detail{
  23. template<typename F,typename Arg1,typename Arg2>
  24. struct promotes_1st_arg:mpl::false_{};
  25. template<typename F,typename Arg1,typename Arg2>
  26. struct promotes_2nd_arg:mpl::false_{};
  27. } /* namespace multi_index::detail */
  28. } /* namespace multi_index */
  29. } /* namespace boost */
  30. #else
  31. #include <boost/mpl/and.hpp>
  32. #include <boost/mpl/bool.hpp>
  33. #include <boost/mpl/not.hpp>
  34. #include <boost/multi_index/detail/is_transparent.hpp>
  35. #include <boost/type_traits/is_convertible.hpp>
  36. namespace boost{
  37. namespace multi_index{
  38. namespace detail{
  39. template<typename F,typename Arg1,typename Arg2>
  40. struct promotes_1st_arg:
  41. mpl::and_<
  42. mpl::not_<is_transparent<F,Arg1,Arg2> >,
  43. is_convertible<const Arg1,Arg2>,
  44. is_transparent<F,Arg2,Arg2>
  45. >
  46. {};
  47. template<typename F,typename Arg1,typename Arg2>
  48. struct promotes_2nd_arg:
  49. mpl::and_<
  50. mpl::not_<is_transparent<F,Arg1,Arg2> >,
  51. is_convertible<const Arg2,Arg1>,
  52. is_transparent<F,Arg1,Arg1>
  53. >
  54. {};
  55. } /* namespace multi_index::detail */
  56. } /* namespace multi_index */
  57. } /* namespace boost */
  58. #endif
  59. #endif