@@ -6,7 +6,7 @@ Real-Time-C++ - Code Snippets
66 <img src="https://github.com/ckormanyos/real-time-cpp/actions/workflows/real-time-cpp-snippets.yml/badge.svg" alt="Build Snippets"></a>
77 <a href="https://github.com/ckormanyos/real-time-cpp/blob/master/LICENSE_1_0.txt">
88 <img src="https://img.shields.io/badge/license-BSL%201.0-blue.svg" alt="Boost Software License 1.0"></a>
9- <a href="https://godbolt.org/z/qfafePavo " alt="godbolt">
9+ <a href="https://godbolt.org/z/9MYejn7cT " alt="godbolt">
1010 <img src="https://img.shields.io/badge/try%20it%20on-godbolt-green" /></a>
1111</p >
1212
@@ -37,39 +37,35 @@ Consider, for instance, the code snippet
3737``` cpp
3838// chapter03_11-001_array.cpp
3939
40- #include < algorithm>
4140#include < array>
42- #include < cstddef>
4341#include < cstdint>
42+ #include < cstddef>
43+ #include < format>
4444#include < iostream>
45- #include < iomanip>
46- #include < iterator>
45+ #include < string>
4746
48- using login_key_array_type = std::array<std::uint8_t , static_cast < std::size_t >( UINT8_C(3 )) >;
47+ using login_key_array_type = std::array<std::uint8_t , std::size_t { UINT8_C (3) } >;
4948
5049// A login key stored in an std::array.
5150
52- constexpr auto login_key =
53- login_key_array_type
51+ constexpr login_key_array_type
52+ login_key
5453 {
55- static_cast<std::uint8_t>( UINT8_C(0x01) ),
56- static_cast<std::uint8_t>( UINT8_C(0x02) ),
57- static_cast<std::uint8_t>( UINT8_C(0x03) )
54+ UINT8_C(0x01),
55+ UINT8_C(0x02),
56+ UINT8_C(0x03)
5857 };
5958
6059auto main() -> int
6160{
62- const auto flg = std::cout.flags() ;
61+ std::string str_login_key { "login_key is: " } ;
6362
64- std::cout.unsetf(std::ios::dec);
65- std::cout.setf(std::ios::hex);
66- std::cout.setf(std::ios::showbase);
67-
68- std::cout << "login_key is ";
69- std::copy (login_key.cbegin(), login_key.cend(), std::ostream_iterator<unsigned int >(std::cout, ","));
70- std::cout << std::endl;
63+ for(const auto& value : login_key)
64+ {
65+ str_login_key += std::format("{:#x},", value);
66+ }
7167
72- std::cout.flags(flg) ;
68+ std::cout << str_login_key << std::endl ;
7369}
7470```
7571
@@ -81,7 +77,7 @@ output console.
8177The expected output message text is
8278
8379```sh
84- login_key is 0x1,0x2,0x3,
80+ login_key is: 0x1,0x2,0x3,
8581```
8682
8783## Testing and CI
@@ -93,11 +89,11 @@ using (at the moment) build-only.
9389## Try it at _ godbolt_
9490
9591<p align =" center " >
96- <a href="https://godbolt.org/z/qfafePavo " alt="godbolt">
92+ <a href="https://godbolt.org/z/9MYejn7cT " alt="godbolt">
9793 <img src="https://img.shields.io/badge/try%20it%20on-godbolt-green" /></a>
9894</p >
9995
100- Use this [ short link] ( https://godbolt.org/z/qfafePavo )
96+ Use this [ short link] https://godbolt.org/z/9MYejn7cT )
10197to [ godbolt] ( https://godbolt.org ) in order to further explore this program.
10298
10399In the afore-mentioned link, the file
0 commit comments