]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/locale/doc/faq.txt
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / locale / doc / faq.txt
1 //
2 // Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //
8
9 // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 filetype=cpp.doxygen
10 /*!
11 \page faq Frequently Asked Questions
12
13 - \anchor faq_bad_cast <b>I try to use some Boost.Locale functions and I get an \c std::bad_cast exception thrown?</b>
14 \n
15 \n
16 \b Answer: You probably try to use incorrect \c std::locale object. All Boost.Locale tools relay on \c std::locale object's facets.
17 The locale object should be generated with \ref boost::locale::generator "generator" class and then passed to
18 the function or alternatively global locale should be set using \c std::locale::global() function such that
19 global locale (and default created one) would have required facets to use.
20 - \anchor faq_number <b>I had installed global locale and try to write something to stream but still get wrong output?</b>
21 For example:
22 \code
23 #include <boost/locale.hpp>
24 #include <iostream>
25 int main()
26 {
27 boost::locale::generator gen;
28 std::locale::global(gen(""));
29 std::cout << boost::locale::as::date << std::time(0) << std::endl;
30 }
31 \endcode
32 Prints a number instead of a date.
33 \n
34 \b Answer: You forget to imbue the locale to the stream. Changing the global locale does not affect the
35 locale in existing \c iostream objects. Thus because \c std::out and other global streams were created
36 before changing the global locale Boost.Locale manipulators have no effect. You need to write:
37 \code
38 #include <boost/locale.hpp>
39 #include <iostream>
40 int main()
41 {
42 boost::locale::generator gen;
43 std::locale l = gen("");
44 std::locale::global(l);
45 std::cout.imbue(l);
46 std::cout << boost::locale::as::date << std::time(0) << std::endl;
47 }
48 \endcode
49
50 */