File: locale_guard.h

package info (click to toggle)
cpprest 2.10.19-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,916 kB
  • sloc: cpp: 71,086; sh: 275; makefile: 170; javascript: 147
file content (34 lines) | stat: -rw-r--r-- 872 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/***
 * Copyright (C) Microsoft. All rights reserved.
 * Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
 *
 * =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
 *
 * Defines an RAII container for setting global locale.
 *
 * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 ****/

#include <locale>

namespace tests
{
namespace common
{
namespace utilities
{
class locale_guard
{
public:
    locale_guard(std::locale const& loc) { m_prev = std::locale::global(loc); }
    ~locale_guard() { std::locale::global(m_prev); }

private:
    std::locale m_prev;
    locale_guard(locale_guard const&);
    locale_guard& operator=(locale_guard const&);
};

} // namespace utilities
} // namespace common
} // namespace tests