utx::wprint is the class object of template class utx::print_class, to print many different printable values to std::wostream based stream. The values to be printed must satisfy utx::wprintable to be printed by utx::wprint.
utx::wprint is similar to utx::print, see utx::print .
utx::print_class is a template class
template <utx::chara char_xt> requires utx::same_as<utx::remove_cvref_t<char_xt>, char_xt> class print_class;
The utx::chara concept requires the type char_xt must be one of char, char8_t, char16_t, char32_t, wchar_t.
The "requires" concept constrains that the type char_xt must not have const and reference.
So char or wchar_t is accepted by utx::print_class template, but const char, char &, or const char &, etc. are not accepted by utx::print_class template.
Currently, only char and wchar_t are implemented by c++ standard ostream, so char8_t, char16_t, char32_t are not available for utx::print_class now.
utx::print_class is inheritence and polymorphism friendly. It has virtual destructor. Its member data or member functions are protected or public.
A constructor must at least set to initialize __sout to attach an external ostream, such as std::cout, or std::wcout.
4x2 constructors
//////////////////////////////////////////////////////////////////////////////// // These two constructors init to attach external ostream print_class(ostream_type & __external_ostream__); print_class(ofstream_type & __external_ofstream__); //////////////////////////////////////////////////////////////////////////////// // These two constructors init to attach external ostream, // and init the three delimiters. print_class( ostream_type & __external_ostream__, const utx::delim_base<string_type> & __init_nested_range_delim__, const utx::delim_base<string_type> & __init_range_delim__, const utx::delim_base<string_type> & __init_value_delim__ ); print_class( ofstream_type & __external_ofstream__, const utx::delim_base<string_type> & __init_nested_range_delim__, const utx::delim_base<string_type> & __init_range_delim__, const utx::delim_base<string_type> & __init_value_delim__ ); //////////////////////////////////////////////////////////////////////////////// // These two constructors init to attach external ostream, // and init if it prints \n at the end, // and if it aligns left for next line printed. print_class( ostream_type & __external_ostream__, utx::mb __newline__, utx::mb __align_left__ ); print_class( ofstream_type & __external_ofstream__, utx::mb __newline__, utx::mb __align_left__ ); //////////////////////////////////////////////////////////////////////////////// // These two constructors init what all above constructors can init. print_class( ostream_type & __external_ostream__, const utx::delim_base<string_type> & __init_nested_range_delim__, const utx::delim_base<string_type> & __init_range_delim__, const utx::delim_base<string_type> & __init_value_delim__, utx::mb __newline__, utx::mb __align_left__ ); print_class( ofstream_type & __external_ofstream__, const utx::delim_base<string_type> & __init_nested_range_delim__, const utx::delim_base<string_type> & __init_range_delim__, const utx::delim_base<string_type> & __init_value_delim__, utx::mb __newline__, utx::mb __align_left__ );
utx::print_class such as utx::print does not include any threading and mutex header, however, you can pass a mutex to utx::print, that mutex will be constrained and matched by utx::param_mutex, then the mutex will be locked and unlocked inside the utx::print calling stack.
std::mutex mutex; start_a_thread; // then use mutex ... utx::print(mutex, "Hell", "World!"); // mutex will be locked and unlocked inside utx::print .
See utx::param_mutex
Every call of utx::print, utx::wprint, etc., the std::boolalpha, std::fixed, and std::setprecision(10) will be set. The user-defined flags can change them, but keep in the current call session, and will be lost after ending current print call, never existed in next print call. No matter how many times of calling utx::print, utx::wprint, etc., and no matter how the user set fmt-flags to utx::print, utx::wprint, etc., the standard output std::cout, std::cerr, std::wcout etc. will be not affected.
#include <utxcpp/core.hpp>
![]() |
Note |
---|---|
|
#include <utxcpp/core.hpp> int main() { utx::wprint(L"Hello", 2023, L"c++!", true, L'M'); }