blob: de9ffb34a2318bc162d9d5568058eb962a9b1833 [file] [log] [blame]
Jeff Thompson86b6d642013-10-17 15:01:56 -07001// (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 NDNBOOST_IOSTREAMS_IMBUE_HPP_INCLUDED
9#define NDNBOOST_IOSTREAMS_IMBUE_HPP_INCLUDED
10
11#if defined(_MSC_VER) && (_MSC_VER >= 1020)
12# pragma once
13#endif
14
15#include <ndnboost/config.hpp> // DEDUCED_TYPENAME, MSVC.
16#include <ndnboost/detail/workaround.hpp>
17#include <ndnboost/iostreams/detail/dispatch.hpp>
18#include <ndnboost/iostreams/detail/streambuf.hpp>
19#include <ndnboost/iostreams/detail/wrap_unwrap.hpp>
20#include <ndnboost/iostreams/operations_fwd.hpp>
21#include <ndnboost/mpl/if.hpp>
22
23// Must come last.
24#include <ndnboost/iostreams/detail/config/disable_warnings.hpp>
25
26namespace ndnboost { namespace iostreams {
27
28namespace detail {
29
30// Implementation templates for simulated tag dispatch.
31template<typename T>
32struct imbue_impl;
33
34} // End namespace detail.
35
36template<typename T, typename Locale>
37void imbue(T& t, const Locale& loc)
38{ detail::imbue_impl<T>::imbue(detail::unwrap(t), loc); }
39
40namespace detail {
41
42//------------------Definition of imbue_impl----------------------------------//
43
44template<typename T>
45struct imbue_impl
46 : mpl::if_<
47 is_custom<T>,
48 operations<T>,
49 imbue_impl<
50 NDNBOOST_DEDUCED_TYPENAME
51 dispatch<
52 T, streambuf_tag, localizable_tag, any_tag
53 >::type
54 >
55 >::type
56 { };
57
58template<>
59struct imbue_impl<any_tag> {
60 template<typename T, typename Locale>
61 static void imbue(T&, const Locale&) { }
62};
63
64template<>
65struct imbue_impl<streambuf_tag> {
66 template<typename T, typename Locale>
67 static void imbue(T& t, const Locale& loc) { t.pubimbue(loc); }
68};
69
70template<>
71struct imbue_impl<localizable_tag> {
72 template<typename T, typename Locale>
73 static void imbue(T& t, const Locale& loc) { t.imbue(loc); }
74};
75
76} // End namespace detail.
77
78} } // End namespaces iostreams, boost.
79
80#include <ndnboost/iostreams/detail/config/enable_warnings.hpp>
81
82#endif // #ifndef NDNBOOST_IOSTREAMS_IMBUE_HPP_INCLUDED