decl.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Copyright (c) 2016 Klemens D. Morgenstern
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_PROCESS_DETAIL_TRAITS_DECL_HPP_
  6. #define BOOST_PROCESS_DETAIL_TRAITS_DECL_HPP_
  7. #include <boost/process/detail/config.hpp>
  8. #include <boost/none.hpp>
  9. #include <type_traits>
  10. #if defined(BOOST_POSIX_API)
  11. #include <boost/process/detail/posix/handler.hpp>
  12. #elif defined(BOOST_WINDOWS_API)
  13. #include <boost/process/detail/windows/handler.hpp>
  14. #endif
  15. namespace boost { namespace process { namespace detail {
  16. template<typename T>
  17. struct is_initializer : std::is_base_of<handler_base, T> {};
  18. template<typename T>
  19. struct is_initializer<T&> : std::is_base_of<handler_base, T> {};
  20. template<typename T>
  21. struct initializer_tag;// { typedef void type; };
  22. //remove const
  23. template<typename T>
  24. struct initializer_tag<const T> { typedef typename initializer_tag<T>::type type; };
  25. //remove &
  26. template<typename T>
  27. struct initializer_tag<T&> { typedef typename initializer_tag<T>::type type; };
  28. //remove const &
  29. template<typename T>
  30. struct initializer_tag<const T&> { typedef typename initializer_tag<T>::type type; };
  31. template<typename T>
  32. struct initializer_builder;
  33. template<typename First, typename ...Args>
  34. struct valid_argument_list;
  35. template<typename First>
  36. struct valid_argument_list<First>
  37. {
  38. constexpr static bool value = is_initializer<First>::value || !std::is_void<typename initializer_tag<First>::type>::value;
  39. typedef std::integral_constant<bool, value> type;
  40. };
  41. template<typename First, typename ...Args>
  42. struct valid_argument_list
  43. {
  44. constexpr static bool my_value = is_initializer<First>::value || !std::is_void<typename initializer_tag<First>::type>::value;
  45. constexpr static bool value = valid_argument_list<Args...>::value && my_value;
  46. typedef std::integral_constant<bool, value> type;
  47. };
  48. }}}
  49. #endif /* BOOST_PROCESS_DETAIL_HANDLER_HPP_ */