get_write_device.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //
  2. // Copyright 2012 Christian Henning
  3. //
  4. // Distributed under the Boost Software License, Version 1.0
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. #ifndef BOOST_GIL_IO_GET_WRITE_DEVICE_HPP
  9. #define BOOST_GIL_IO_GET_WRITE_DEVICE_HPP
  10. #include <boost/gil/detail/mp11.hpp>
  11. #include <boost/gil/io/device.hpp>
  12. #include <boost/gil/io/path_spec.hpp>
  13. #include <type_traits>
  14. namespace boost { namespace gil {
  15. template <typename T, typename FormatTag, class Enable = void>
  16. struct get_write_device {};
  17. template <typename Device, typename FormatTag>
  18. struct get_write_device
  19. <
  20. Device,
  21. FormatTag,
  22. typename std::enable_if
  23. <
  24. mp11::mp_and
  25. <
  26. detail::is_adaptable_output_device<FormatTag, Device>,
  27. is_format_tag<FormatTag>
  28. >::value
  29. >::type
  30. >
  31. {
  32. using type =
  33. typename detail::is_adaptable_output_device<FormatTag, Device>::device_type;
  34. };
  35. template <typename String, typename FormatTag>
  36. struct get_write_device
  37. <
  38. String,
  39. FormatTag,
  40. typename std::enable_if
  41. <
  42. mp11::mp_and
  43. <
  44. detail::is_supported_path_spec<String>,
  45. is_format_tag<FormatTag>
  46. >::value
  47. >::type
  48. >
  49. {
  50. using type = detail::file_stream_device<FormatTag>;
  51. };
  52. }} // namespace boost::gil
  53. #endif