Boost GIL


get_write_device.hpp
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 
11 #include <boost/gil/detail/mp11.hpp>
12 #include <boost/gil/io/device.hpp>
13 #include <boost/gil/io/path_spec.hpp>
14 
15 #include <type_traits>
16 
17 namespace boost { namespace gil {
18 
19 template <typename T, typename FormatTag, class Enable = void>
20 struct get_write_device {};
21 
22 template <typename Device, typename FormatTag>
23 struct get_write_device
24 <
25  Device,
26  FormatTag,
27  typename std::enable_if
28  <
29  mp11::mp_and
30  <
31  detail::is_adaptable_output_device<FormatTag, Device>,
32  is_format_tag<FormatTag>
33  >::value
34  >::type
35 >
36 {
37  using type =
38  typename detail::is_adaptable_output_device<FormatTag, Device>::device_type;
39 };
40 
41 template <typename String, typename FormatTag>
42 struct get_write_device
43 <
44  String,
45  FormatTag,
46  typename std::enable_if
47  <
48  mp11::mp_and
49  <
50  detail::is_supported_path_spec<String>,
51  is_format_tag<FormatTag>
52  >::value
53  >::type
54 >
55 {
56  using type = detail::file_stream_device<FormatTag>;
57 };
58 
59 }} // namespace boost::gil
60 
61 #endif