]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/iostreams/include/boost/iostreams/detail/translate_int_type.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / iostreams / include / boost / iostreams / detail / translate_int_type.hpp
CommitLineData
7c673cae
FG
1// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
2// (C) Copyright 2003-2007 Jonathan Turkanis
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
6// See http://www.boost.org/libs/iostreams for documentation.
7
8#ifndef BOOST_IOSTREAMS_DETAIL_TRANSLATE_INT_TYPE_HPP_INCLUDED
9#define BOOST_IOSTREAMS_DETAIL_TRANSLATE_INT_TYPE_HPP_INCLUDED
10
11#if defined(_MSC_VER)
12# pragma once
13#endif
14
15#include <boost/type_traits/is_same.hpp>
16
17namespace boost { namespace iostreams { namespace detail {
18
19template<bool IsSame>
20struct translate_int_type_impl;
21
22//
23// Template name: translate_char.
24// Description: Translates a character or an end-of-file indicator from the
25// int_type of one character traits type to the int_type of another.
26//
27template<typename SourceTr, typename TargetTr>
28typename TargetTr::int_type
29translate_int_type(typename SourceTr::int_type c)
30{
31 typedef translate_int_type_impl<is_same<SourceTr, TargetTr>::value> impl;
32 return impl::template inner<SourceTr, TargetTr>::translate(c);
33}
34
35//----------------------------------------------------------------------------//
36
37template<>
38struct translate_int_type_impl<true> {
39 template<typename SourceTr, typename TargetTr>
40 struct inner {
41 static typename TargetTr::int_type
42 translate(typename SourceTr::int_type c) { return c; }
43 };
44};
45
46template<>
47struct translate_int_type_impl<false> {
48 template<typename SourceTr, typename TargetTr>
49 struct inner {
50 static typename TargetTr::int_type
51 translate(typename SourceTr::int_type c)
52 {
53 return SourceTr::eq_int_type(SourceTr::eof()) ?
54 TargetTr::eof() :
55 TargetTr::to_int_type(SourceTr::to_char_type(c));
56 }
57 };
58};
59
60} } } // End namespaces detail, iostreams, boost.
61
62#endif // #ifndef BOOST_IOSTREAMS_DETAIL_TRANSLATE_INT_TYPE_HPP_INCLUDED