-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInsertion.cpp
More file actions
50 lines (38 loc) · 1.23 KB
/
Insertion.cpp
File metadata and controls
50 lines (38 loc) · 1.23 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* \file Insertion.cpp
* \brief Output stream insertion (<<) operator for custom types
*/
#include <StdStream/StdStream.h>
#include <StdTest/StdTest.h>
#include <Stl.h>
//--------------------------------------------------------------------------------------------------
namespace std
{
using ustring_t = basic_string<unsigned char, char_traits<unsigned char>, allocator<unsigned char>>;
}
//--------------------------------------------------------------------------------------------------
std::basic_ostringstream<char>&
operator << (
std::basic_ostringstream<char> &out_os,
const std::ustring_t &a_value
)
{
const std::string sRv(a_value.cbegin(), a_value.cend());
out_os << sRv << std::flush;
return out_os;
}
//--------------------------------------------------------------------------------------------------
int main(int, char **)
{
const std::ustring_t sRv1(4, 'a');
const std::ustring_t sRv2(1, '-');
const std::ustring_t sRv3(4, 'b');
std::ostringstream oss;
oss << sRv1 << sRv2 << sRv3;
std::cout << oss.str() << std::endl;
return EXIT_SUCCESS;
}
//--------------------------------------------------------------------------------------------------
#if OUTPUT
aaaa-bbbb
#endif