source: NonGTP/Boost/boost/iostreams/imbue.hpp @ 857

Revision 857, 2.2 KB checked in by igarcia, 18 years ago (diff)
Line 
1// (C) Copyright Jonathan Turkanis 2003.
2// Distributed under the Boost Software License, Version 1.0. (See accompanying
3// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
4
5// See http://www.boost.org/libs/iostreams for documentation.
6
7#ifndef BOOST_IOSTREAMS_IMBUE_HPP_INCLUDED
8#define BOOST_IOSTREAMS_IMBUE_HPP_INCLUDED
9
10#if defined(_MSC_VER) && (_MSC_VER >= 1020)
11# pragma once
12#endif
13
14#include <boost/config.hpp>  // DEDUCED_TYPENAME, MSVC.
15#include <boost/detail/workaround.hpp>
16#include <boost/iostreams/detail/dispatch.hpp>
17#include <boost/iostreams/detail/streambuf.hpp>
18#include <boost/iostreams/detail/wrap_unwrap.hpp>
19#include <boost/iostreams/operations_fwd.hpp>
20#include <boost/mpl/if.hpp>
21
22// Must come last.
23#include <boost/iostreams/detail/config/disable_warnings.hpp>
24
25namespace boost { namespace iostreams {
26
27namespace detail {
28
29// Implementation templates for simulated tag dispatch.
30template<typename T>
31struct imbue_impl;
32
33} // End namespace detail.
34
35template<typename T, typename Locale>
36void imbue(T& t, const Locale& loc)
37{ detail::imbue_impl<T>::imbue(detail::unwrap(t), loc); }
38
39namespace detail {
40
41//------------------Definition of imbue_impl----------------------------------//
42
43template<typename T>
44struct imbue_impl
45    : mpl::if_<
46          is_custom<T>,
47          operations<T>,
48          imbue_impl<
49              BOOST_DEDUCED_TYPENAME
50              dispatch<
51                  T, streambuf_tag, localizable_tag, any_tag
52              >::type
53          >
54      >::type
55    { };
56
57template<>
58struct imbue_impl<any_tag> {
59    template<typename T, typename Locale>
60    static void imbue(T&, const Locale&) { }
61};
62
63template<>
64struct imbue_impl<streambuf_tag> {
65    template<typename T, typename Locale>
66    static void imbue(T& t, const Locale& loc) { t.pubimbue(loc); }
67};
68
69template<>
70struct imbue_impl<localizable_tag> {
71    template<typename T, typename Locale>
72    static void imbue(T& t, const Locale& loc) { t.imbue(loc); }
73};
74
75} // End namespace detail.
76
77} } // End namespaces iostreams, boost.
78
79#include <boost/iostreams/detail/config/enable_warnings.hpp>
80
81#endif // #ifndef BOOST_IOSTREAMS_IMBUE_HPP_INCLUDED
Note: See TracBrowser for help on using the repository browser.