\hypertarget{io_8h_source}{}\doxysection{io.\+h} \label{io_8h_source}\index{kblib/io.h@{kblib/io.h}} \mbox{\hyperlink{io_8h}{Go to the documentation of this file.}} \begin{DoxyCode}{0} \DoxyCodeLine{\Hypertarget{io_8h_source_l00001}00001 \textcolor{comment}{/* *****************************************************************************}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00002}00002 \textcolor{comment}{ * kblib is a general utility library for C++14 and C++17, intended to provide}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00003}00003 \textcolor{comment}{ * performant high-\/level abstractions and more expressive ways to do simple}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00004}00004 \textcolor{comment}{ * things.}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00005}00005 \textcolor{comment}{ *}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00006}00006 \textcolor{comment}{ * Copyright (c) 2021 killerbee}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00007}00007 \textcolor{comment}{ *}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00008}00008 \textcolor{comment}{ * This program is free software: you can redistribute it and/or modify}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00009}00009 \textcolor{comment}{ * it under the terms of the GNU General Public License as published by}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00010}00010 \textcolor{comment}{ * the Free Software Foundation, either version 3 of the License, or}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00011}00011 \textcolor{comment}{ * (at your option) any later version.}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00012}00012 \textcolor{comment}{ *}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00013}00013 \textcolor{comment}{ * This program is distributed in the hope that it will be useful,}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00014}00014 \textcolor{comment}{ * but WITHOUT ANY WARRANTY; without even the implied warranty of}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00015}00015 \textcolor{comment}{ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00016}00016 \textcolor{comment}{ * GNU General Public License for more details.}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00017}00017 \textcolor{comment}{ *}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00018}00018 \textcolor{comment}{ * You should have received a copy of the GNU General Public License}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00019}00019 \textcolor{comment}{ * along with this program. If not, see .}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00020}00020 \textcolor{comment}{ * ****************************************************************************/}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00021}00021 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00031}00031 \textcolor{preprocessor}{\#ifndef KBLIB\_IO\_H}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00032}00032 \textcolor{preprocessor}{\#define KBLIB\_IO\_H}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00033}00033 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00034}00034 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{fakestd_8h}{fakestd.h}}"{}}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00035}00035 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{traits_8h}{traits.h}}"{}}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00036}00036 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00037}00037 \textcolor{preprocessor}{\#include }} \DoxyCodeLine{\Hypertarget{io_8h_source_l00038}00038 \textcolor{preprocessor}{\#include }} \DoxyCodeLine{\Hypertarget{io_8h_source_l00039}00039 \textcolor{preprocessor}{\#include }} \DoxyCodeLine{\Hypertarget{io_8h_source_l00040}00040 \textcolor{preprocessor}{\#include }} \DoxyCodeLine{\Hypertarget{io_8h_source_l00041}00041 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00042}00042 \textcolor{preprocessor}{\#if KBLIB\_USE\_CXX17}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00043}00043 \textcolor{preprocessor}{\# include }} \DoxyCodeLine{\Hypertarget{io_8h_source_l00044}00044 \textcolor{preprocessor}{\# include }} \DoxyCodeLine{\Hypertarget{io_8h_source_l00045}00045 \textcolor{preprocessor}{\# include }} \DoxyCodeLine{\Hypertarget{io_8h_source_l00046}00046 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00047}00047 \textcolor{preprocessor}{\# if ! defined(\_WIN32) \(\backslash\)}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00048}00048 \textcolor{preprocessor}{ \&\& (defined(\_\_unix\_\_) || defined(\_\_unix) \(\backslash\)}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00049}00049 \textcolor{preprocessor}{ || (defined(\_\_APPLE\_\_) \&\& defined(\_\_MACH\_\_)))}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00050}00050 \textcolor{comment}{/* UNIX-\/style OS. -\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/ */}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00051}00051 \textcolor{preprocessor}{\# include }} \DoxyCodeLine{\Hypertarget{io_8h_source_l00052}00052 \textcolor{preprocessor}{\# if defined(\_POSIX\_VERSION)}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00053}00053 \textcolor{preprocessor}{\# define KBLIB\_POSIX\_TMPFILE}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00054}00054 \textcolor{preprocessor}{\# endif}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00055}00055 \textcolor{preprocessor}{\# endif}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00056}00056 \textcolor{preprocessor}{\#endif}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00057}00057 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00058}00058 \textcolor{preprocessor}{\#include }} \DoxyCodeLine{\Hypertarget{io_8h_source_l00059}00059 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00060}00060 \textcolor{keyword}{namespace }\mbox{\hyperlink{tdecl_8h_a4b5c574c663a392148218cd4410fd7a1}{KBLIB\_NS}} \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00061}00061 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00062}00062 \textcolor{keyword}{template} <\textcolor{keyword}{typename} D = std::string,} \DoxyCodeLine{\Hypertarget{io_8h_source_l00063}00063 \textcolor{keyword}{typename} std::enable\_if\_t, \textcolor{keywordtype}{int}> = 0>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00064}\mbox{\hyperlink{namespacekblib_a629b6bb6b53b02c3ae0129ddc128eb5c}{00064}} \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_a629b6bb6b53b02c3ae0129ddc128eb5c}{get\_contents}}(std::istream\& in, D\& out) -\/> \textcolor{keyword}{auto} \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00065}00065 in.seekg(0, std::ios::end);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00066}00066 \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_1_1fakestd_adb8781bc0e5d1ba4ca4624293c0c98ae}{size}} = in.tellg();} \DoxyCodeLine{\Hypertarget{io_8h_source_l00067}00067 out.resize(\textcolor{keyword}{static\_cast<}std::size\_t\textcolor{keyword}{>}(\mbox{\hyperlink{namespacekblib_1_1fakestd_adb8781bc0e5d1ba4ca4624293c0c98ae}{size}}));} \DoxyCodeLine{\Hypertarget{io_8h_source_l00068}00068 in.seekg(0, std::ios::beg);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00069}00069 in.read(\textcolor{keyword}{reinterpret\_cast<}\textcolor{keywordtype}{char}*\textcolor{keyword}{>}(out.data()), \mbox{\hyperlink{namespacekblib_1_1fakestd_adb8781bc0e5d1ba4ca4624293c0c98ae}{size}});} \DoxyCodeLine{\Hypertarget{io_8h_source_l00070}00070 \textcolor{keywordflow}{return} \mbox{\hyperlink{namespacekblib_1_1fakestd_adb8781bc0e5d1ba4ca4624293c0c98ae}{size}};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00071}00071 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00072}00072 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00073}00073 \textcolor{keyword}{template} <\textcolor{keyword}{typename} D = std::string,} \DoxyCodeLine{\Hypertarget{io_8h_source_l00074}00074 \textcolor{keyword}{typename} std::enable\_if\_t, \textcolor{keywordtype}{int}> = 0>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00075}00075 \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_a629b6bb6b53b02c3ae0129ddc128eb5c}{get\_contents}}(std::istream\& in, D\& out) -\/> \textcolor{keyword}{auto} \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00076}00076 in.seekg(0, std::ios::end);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00077}00077 \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_1_1fakestd_adb8781bc0e5d1ba4ca4624293c0c98ae}{size}} = in.tellg();} \DoxyCodeLine{\Hypertarget{io_8h_source_l00078}00078 out.resize(\textcolor{keyword}{static\_cast<}std::size\_t\textcolor{keyword}{>}(\mbox{\hyperlink{namespacekblib_1_1fakestd_adb8781bc0e5d1ba4ca4624293c0c98ae}{size}}));} \DoxyCodeLine{\Hypertarget{io_8h_source_l00079}00079 in.seekg(0, std::ios::beg);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00080}00080 \mbox{\hyperlink{namespacekblib_ac912dd210d34963da9bd40a1a6296308}{std::copy}}((std::istreambuf\_iterator(in)),} \DoxyCodeLine{\Hypertarget{io_8h_source_l00081}00081 std::istreambuf\_iterator(), out.begin());} \DoxyCodeLine{\Hypertarget{io_8h_source_l00082}00082 \textcolor{keywordflow}{return} \mbox{\hyperlink{namespacekblib_1_1fakestd_adb8781bc0e5d1ba4ca4624293c0c98ae}{size}};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00083}00083 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00084}00084 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00085}00085 \textcolor{preprocessor}{\#if KBLIB\_USE\_CXX17}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00096}00096 \textcolor{keyword}{template} <\textcolor{keyword}{typename} D = std::\textcolor{keywordtype}{string}, \textcolor{keyword}{typename} \textcolor{keywordtype}{string}>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00097}\mbox{\hyperlink{namespacekblib_a842d755850ee1a876ee0587931a7bd16}{00097}} \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_a842d755850ee1a876ee0587931a7bd16}{get\_file\_contents}}(\textcolor{keyword}{const} \textcolor{keywordtype}{string}\& filename) -\/> std::optional \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00098}00098 \textcolor{keyword}{static\_assert}(std::is\_trivially\_copyable\_v,} \DoxyCodeLine{\Hypertarget{io_8h_source_l00099}00099 \textcolor{stringliteral}{"{}D must be a sequence of trivial types"{}});} \DoxyCodeLine{\Hypertarget{io_8h_source_l00100}00100 \textcolor{keyword}{static\_assert}(\textcolor{keyword}{sizeof}(\textcolor{keyword}{typename} D::value\_type) == 1,} \DoxyCodeLine{\Hypertarget{io_8h_source_l00101}00101 \textcolor{stringliteral}{"{}D must be a sequence of char-\/sized objects."{}});} \DoxyCodeLine{\Hypertarget{io_8h_source_l00102}00102 std::optional out;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00103}00103 \textcolor{keywordflow}{if} (std::ifstream in(filename, std::ios::in | std::ios::binary); in) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00104}00104 \textcolor{keyword}{const} \textcolor{keyword}{auto} fsize = \mbox{\hyperlink{namespacekblib_a629b6bb6b53b02c3ae0129ddc128eb5c}{get\_contents}}(in, out.emplace());} \DoxyCodeLine{\Hypertarget{io_8h_source_l00105}00105 \textcolor{keywordflow}{if} (fsize != \mbox{\hyperlink{namespacekblib_a1909a64960663825ccc4eb98e4637df2}{to\_signed}}(out-\/>size())) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00106}00106 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00107}00107 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00108}00108 \textcolor{keywordflow}{return} out;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00109}00109 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00110}00110 \textcolor{preprocessor}{\#endif}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00111}00111 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00122}00122 \textcolor{keyword}{template} <\textcolor{keyword}{typename} D = std::\textcolor{keywordtype}{string}, \textcolor{keyword}{typename} \textcolor{keywordtype}{string}>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00123}\mbox{\hyperlink{namespacekblib_a28d32b32bd6bbd28e27a80c236d46cd2}{00123}} \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_a28d32b32bd6bbd28e27a80c236d46cd2}{try\_get\_file\_contents}}(\textcolor{keyword}{const} \textcolor{keywordtype}{string}\& filename) -\/> D \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00124}00124 \textcolor{keyword}{static\_assert}(std::is\_trivially\_copyable::value,} \DoxyCodeLine{\Hypertarget{io_8h_source_l00125}00125 \textcolor{stringliteral}{"{}D must be a sequence of trivial types"{}});} \DoxyCodeLine{\Hypertarget{io_8h_source_l00126}00126 \textcolor{keyword}{static\_assert}(\textcolor{keyword}{sizeof}(\textcolor{keyword}{typename} D::value\_type) == 1,} \DoxyCodeLine{\Hypertarget{io_8h_source_l00127}00127 \textcolor{stringliteral}{"{}D must be a sequence of char-\/sized objects."{}});} \DoxyCodeLine{\Hypertarget{io_8h_source_l00128}00128 D out;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00129}00129 std::ifstream in(filename, std::ios::in | std::ios::binary);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00130}00130 \textcolor{keywordflow}{if} (in) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00131}00131 in.exceptions(std::ios\_base::failbit | std::ios\_base::badbit);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00132}00132 \mbox{\hyperlink{namespacekblib_a629b6bb6b53b02c3ae0129ddc128eb5c}{get\_contents}}(in, out);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00133}00133 \} \textcolor{keywordflow}{else} \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00134}00134 \textcolor{keywordflow}{throw} std::system\_error(std::make\_error\_code(std::errc::io\_error),} \DoxyCodeLine{\Hypertarget{io_8h_source_l00135}00135 \textcolor{stringliteral}{"{}could not open file "{}} + std::string(filename));} \DoxyCodeLine{\Hypertarget{io_8h_source_l00136}00136 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00137}00137 \textcolor{keywordflow}{return} out;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00138}00138 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00139}00139 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00146}\mbox{\hyperlink{namespacekblib_a8ec120cbc5e4f7c1624f07e48660b7f9}{00146}} \textcolor{keyword}{inline} \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_a8ec120cbc5e4f7c1624f07e48660b7f9}{getline}}(std::istream\& is) -\/> std::string \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00147}00147 std::string ret;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00148}00148 \mbox{\hyperlink{namespacekblib_a8ec120cbc5e4f7c1624f07e48660b7f9}{std::getline}}(is, ret);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00149}00149 \textcolor{keywordflow}{return} ret;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00150}00150 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00151}00151 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00158}\mbox{\hyperlink{namespacekblib_a09ae80b5cc20a7bcb10eda5d227c5b22}{00158}} \textcolor{keyword}{inline} \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_a09ae80b5cc20a7bcb10eda5d227c5b22}{eat\_word}}(std::istream\& is) -\/> std::istream\& \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00159}00159 \textcolor{keywordflow}{do} \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00160}00160 is.get();} \DoxyCodeLine{\Hypertarget{io_8h_source_l00161}00161 \} \textcolor{keywordflow}{while} (is and not \mbox{\hyperlink{namespacekblib_a9ac0c26180c8c2c92776c9f5ab5d9cb5}{std::isspace}}(is.peek()));} \DoxyCodeLine{\Hypertarget{io_8h_source_l00162}00162 \textcolor{keywordflow}{return} is;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00163}00163 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00164}00164 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00173}\mbox{\hyperlink{namespacekblib_a892c5cf646b0bd6fbe72caa7cd6afa3a}{00173}} [[deprecated(\textcolor{stringliteral}{"{}Use std::ws instead"{}})]] \textcolor{keyword}{inline} std::istream\& \mbox{\hyperlink{namespacekblib_a892c5cf646b0bd6fbe72caa7cd6afa3a}{eat\_space}}(} \DoxyCodeLine{\Hypertarget{io_8h_source_l00174}00174 std::istream\& is) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00175}00175 \textcolor{keywordflow}{while} (is and \mbox{\hyperlink{namespacekblib_a9ac0c26180c8c2c92776c9f5ab5d9cb5}{std::isspace}}(is.peek())) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00176}00176 is.get();} \DoxyCodeLine{\Hypertarget{io_8h_source_l00177}00177 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00178}00178 \textcolor{keywordflow}{return} is;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00179}00179 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00180}00180 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00184}00184 \textcolor{keyword}{template} <\textcolor{keyword}{typename} F>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00185}\mbox{\hyperlink{structkblib_1_1get__manip}{00185}} \textcolor{keyword}{struct }\mbox{\hyperlink{structkblib_1_1get__manip}{get\_manip}} \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00186}\mbox{\hyperlink{structkblib_1_1get__manip_ad6c96adbf37dba3102defbb2ac1816f0}{00186}} F \mbox{\hyperlink{structkblib_1_1get__manip_ad6c96adbf37dba3102defbb2ac1816f0}{\_f}};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00187}00187 \};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00188}00188 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00211}00211 \textcolor{keyword}{template} <\textcolor{keyword}{typename} CharT, \textcolor{keyword}{typename} Traits>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00212}\mbox{\hyperlink{namespacekblib_a1c69e2ede07e021b4a480b78496912e2}{00212}} \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_a1c69e2ede07e021b4a480b78496912e2}{nl}}(std::basic\_istream\& is)} \DoxyCodeLine{\Hypertarget{io_8h_source_l00213}00213 -\/> std::basic\_istream\& \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00214}00214 \textcolor{keyword}{auto} n = \textcolor{keyword}{static\_cast<}typename Traits::int\_type\textcolor{keyword}{>}(is.widen(\textcolor{charliteral}{'\(\backslash\)n'}));} \DoxyCodeLine{\Hypertarget{io_8h_source_l00215}00215 \textcolor{keywordflow}{for} (\textcolor{keyword}{typename} Traits::int\_type c = is.peek();} \DoxyCodeLine{\Hypertarget{io_8h_source_l00216}00216 is and c != \mbox{\hyperlink{namespacekblib_af23ee1a0fd16161a62159681c8cf6e16}{Traits::eof}}()} \DoxyCodeLine{\Hypertarget{io_8h_source_l00217}00217 and \mbox{\hyperlink{namespacekblib_a9ac0c26180c8c2c92776c9f5ab5d9cb5}{std::isspace}}(\textcolor{keyword}{static\_cast<}CharT\textcolor{keyword}{>}(c), is.getloc()) and c != n;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00218}00218 c = is.peek()) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00219}00219 is.ignore();} \DoxyCodeLine{\Hypertarget{io_8h_source_l00220}00220 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00221}00221 \textcolor{keywordflow}{if} (is.peek() == n) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00222}00222 is.ignore();} \DoxyCodeLine{\Hypertarget{io_8h_source_l00223}00223 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00224}00224 \textcolor{keywordflow}{return} is;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00225}00225 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00226}00226 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00227}00227 \textcolor{keyword}{template} <\textcolor{keyword}{typename} T, \textcolor{keyword}{typename} U>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00228}\mbox{\hyperlink{structkblib_1_1unicode__widen}{00228}} \textcolor{keyword}{struct }\mbox{\hyperlink{structkblib_1_1unicode__widen}{unicode\_widen}} : std::false\_type \{\};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00229}00229 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00230}00230 \textcolor{keyword}{template} <>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00231}\mbox{\hyperlink{structkblib_1_1unicode__widen_3_01char16__t_00_01char32__t_01_4}{00231}} \textcolor{keyword}{struct }\mbox{\hyperlink{structkblib_1_1unicode__widen}{unicode\_widen}} : std::true\_type \{\};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00232}00232 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00233}00233 \textcolor{preprocessor}{\#if KBLIB\_USE\_CHAR8\_T}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00234}00234 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00235}00235 \textcolor{keyword}{template} <>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00236}00236 \textcolor{keyword}{struct }\mbox{\hyperlink{structkblib_1_1unicode__widen}{unicode\_widen}} : std::true\_type \{\};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00237}00237 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00238}00238 \textcolor{keyword}{template} <>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00239}00239 \textcolor{keyword}{struct }unicode\_widen : std::true\_type \{\};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00240}00240 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00241}00241 \textcolor{preprocessor}{\#endif}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00242}00242 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00243}00243 \textcolor{preprocessor}{\#if KBLIB\_CHAR\_IS\_UTF8}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00244}00244 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00245}00245 \textcolor{keyword}{template} <>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00246}00246 \textcolor{keyword}{struct }unicode\_widen : std::true\_type \{\};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00247}00247 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00248}00248 \textcolor{keyword}{template} <>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00249}00249 \textcolor{keyword}{struct }unicode\_widen : std::true\_type \{\};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00250}00250 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00251}00251 \textcolor{preprocessor}{\#endif}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00252}00252 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00253}00253 \textcolor{keyword}{template} <\textcolor{keyword}{typename} T, \textcolor{keyword}{typename} U>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00254}00254 \textcolor{keyword}{constexpr} \textcolor{keyword}{static} \textcolor{keywordtype}{bool} unicode\_widen\_v = unicode\_widen::value;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00255}00255 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00261}00261 \textcolor{keyword}{template} <\textcolor{keyword}{typename} CharT>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00262}\mbox{\hyperlink{namespacekblib_a667a06da2b3ec8f82f8a22aee03e46d7}{00262}} \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_a667a06da2b3ec8f82f8a22aee03e46d7}{unformatted\_expect}}(CharT c) -\/> \textcolor{keyword}{auto} \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00263}00263 \textcolor{keyword}{auto} \_f = [c](\textcolor{keyword}{auto}\& istream) -\/> \textcolor{keyword}{decltype}(istream) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00264}00264 \textcolor{keyword}{using }SCharT = \textcolor{keyword}{typename} \mbox{\hyperlink{namespacekblib_a9dcf2233bc360ff26fbbf82d98cdc64d}{std::decay\_t}}<\textcolor{keyword}{decltype}(istream)>::char\_type;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00265}00265 \textcolor{preprocessor}{\#if KBLIB\_USE\_CHAR8\_t}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00266}00266 \textcolor{comment}{// clang-\/format off}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00267}00267 \textcolor{keyword}{static\_assert}(} \DoxyCodeLine{\Hypertarget{io_8h_source_l00268}00268 std::is\_same\_v} \DoxyCodeLine{\Hypertarget{io_8h_source_l00269}00269 or (not std::is\_same\_v} \DoxyCodeLine{\Hypertarget{io_8h_source_l00270}00270 and not std::is\_same\_v),} \DoxyCodeLine{\Hypertarget{io_8h_source_l00271}00271 \textcolor{stringliteral}{"{}No support for char8\_t conversions."{}});} \DoxyCodeLine{\Hypertarget{io_8h_source_l00272}00272 \textcolor{comment}{// clang-\/format on}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00273}00273 \textcolor{preprocessor}{\#endif}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00274}00274 \textcolor{keyword}{auto} widen\_equal = [\&](\textcolor{keyword}{auto} di) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00275}00275 \textcolor{keywordflow}{if} (di == \mbox{\hyperlink{namespacekblib_a9dcf2233bc360ff26fbbf82d98cdc64d}{std::decay\_t}}<\textcolor{keyword}{decltype}(istream)>\mbox{\hyperlink{namespacekblib_af23ee1a0fd16161a62159681c8cf6e16}{::traits\_type::eof}}()) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00276}00276 \textcolor{keywordflow}{return} \textcolor{keyword}{false};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00277}00277 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00278}00278 \textcolor{keyword}{auto} d = \textcolor{keyword}{static\_cast<}SCharT\textcolor{keyword}{>}(di);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00279}00279 \textcolor{comment}{// Feasible:}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00280}00280 \textcolor{comment}{// T -\/> T : c == d}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00281}00281 \textcolor{comment}{// T -\/> char : istream.widen(c) == d}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00282}00282 \textcolor{comment}{// u32 -\/> u16 : c == d}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00283}00283 \textcolor{comment}{// Not currently feasible:}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00284}00284 \textcolor{comment}{// SCharT == char : read multiple chars and convert to CharT?}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00285}00285 \textcolor{comment}{// ... : convert between different wide char types?}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00286}00286 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00287}00287 \textcolor{keyword}{static\_assert}(} \DoxyCodeLine{\Hypertarget{io_8h_source_l00288}00288 (std::is\_same::value} \DoxyCodeLine{\Hypertarget{io_8h_source_l00289}00289 or std::is\_same::value),} \DoxyCodeLine{\Hypertarget{io_8h_source_l00290}00290 \textcolor{stringliteral}{"{}Stream character type incompatible with argument type."{}});} \DoxyCodeLine{\Hypertarget{io_8h_source_l00291}00291 \textcolor{preprocessor}{\#if KBLIB\_USE\_CXX17}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00292}00292 \textcolor{preprocessor}{\# define IF\_CONSTEXPR constexpr}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00293}00293 \textcolor{preprocessor}{\#else}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00294}00294 \textcolor{preprocessor}{\# define IF\_CONSTEXPR}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00295}00295 \textcolor{preprocessor}{\#endif}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00296}00296 \textcolor{keywordflow}{if} \mbox{\hyperlink{io_8h_a47ec10d8c001b6c6d05b8c88c9dbe554}{IF\_CONSTEXPR}} (std::is\_same::value) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00297}00297 \textcolor{keywordflow}{return} c == d;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00298}00298 \} \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} \mbox{\hyperlink{io_8h_a47ec10d8c001b6c6d05b8c88c9dbe554}{IF\_CONSTEXPR}} (unicode\_widen\_v) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00299}00299 \textcolor{keywordflow}{return} c == d;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00300}00300 \} \textcolor{keywordflow}{else} \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00301}00301 \textcolor{keywordflow}{return} istream.widen(c) == d;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00302}00302 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00303}00303 \textcolor{preprocessor}{\#undef IF\_CONSTEXPR}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00304}00304 \};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00305}00305 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00306}00306 \textcolor{keywordflow}{if} (widen\_equal(istream.peek())) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00307}00307 void(istream.get());} \DoxyCodeLine{\Hypertarget{io_8h_source_l00308}00308 \} \textcolor{keywordflow}{else} \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00309}00309 istream.setstate(std::ios\_base::failbit);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00310}00310 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00311}00311 \textcolor{keywordflow}{return} istream;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00312}00312 \};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00313}00313 \textcolor{keywordflow}{return} \mbox{\hyperlink{structkblib_1_1get__manip}{get\_manip}}<\textcolor{keyword}{decltype}(\_f)>\{\_f\};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00314}00314 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00315}00315 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00320}00320 \textcolor{keyword}{template} <\textcolor{keyword}{typename} CharT>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00321}\mbox{\hyperlink{namespacekblib_a92cc98441a6881da833d69dad234f8be}{00321}} \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_a92cc98441a6881da833d69dad234f8be}{expect}}(CharT c) -\/> \textcolor{keyword}{auto} \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00322}00322 \textcolor{keyword}{auto} \_f = [c](\textcolor{keyword}{auto}\& istream) -\/> \textcolor{keyword}{decltype}(istream) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00323}00323 \textcolor{keywordflow}{return} istream >> std::ws >> \mbox{\hyperlink{namespacekblib_a667a06da2b3ec8f82f8a22aee03e46d7}{unformatted\_expect}}(c);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00324}00324 \};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00325}00325 \textcolor{keywordflow}{return} \mbox{\hyperlink{structkblib_1_1get__manip}{get\_manip}}<\textcolor{keyword}{decltype}(\_f)>\{\_f\};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00326}00326 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00327}00327 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00338}00338 \textcolor{keyword}{template} <\textcolor{keyword}{typename} CharT, \textcolor{keyword}{typename}... O,} \DoxyCodeLine{\Hypertarget{io_8h_source_l00339}00339 \textcolor{keyword}{template} <\textcolor{keyword}{typename}, \textcolor{keyword}{typename}...> \textcolor{keyword}{class }\textcolor{keywordtype}{string}>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00340}\mbox{\hyperlink{namespacekblib_ab094fc53f62f0f36e6f68eb3a4e70d5b}{00340}} \textcolor{keyword}{inline} \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_a6ceffff6280ce849da581b3d46ce495b}{get\_line}}(string\& str) -\/> \textcolor{keyword}{auto} \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00341}00341 \textcolor{keyword}{auto} \_f = [\&](\textcolor{keyword}{auto}\& istream) -\/> \textcolor{keyword}{decltype}(istream) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00342}00342 \mbox{\hyperlink{namespacekblib_a8ec120cbc5e4f7c1624f07e48660b7f9}{std::getline}}(istream, str);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00343}00343 \textcolor{keywordflow}{return} istream;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00344}00344 \};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00345}00345 \textcolor{keywordflow}{return} \mbox{\hyperlink{structkblib_1_1get__manip}{get\_manip}}<\textcolor{keyword}{decltype}(\_f)>\{\_f\};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00346}00346 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00347}00347 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00359}00359 \textcolor{keyword}{template} <\textcolor{keyword}{typename} CharT, \textcolor{keyword}{typename}... O,} \DoxyCodeLine{\Hypertarget{io_8h_source_l00360}00360 \textcolor{keyword}{template} <\textcolor{keyword}{typename}, \textcolor{keyword}{typename}...> \textcolor{keyword}{class }\textcolor{keywordtype}{string}>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00361}\mbox{\hyperlink{namespacekblib_a6ceffff6280ce849da581b3d46ce495b}{00361}} \textcolor{keyword}{inline} \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_a6ceffff6280ce849da581b3d46ce495b}{get\_line}}(string\& str, CharT delim) -\/> \textcolor{keyword}{auto} \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00362}00362 \textcolor{keyword}{auto} \_f = [\&, delim](\textcolor{keyword}{auto}\& istream) -\/> \textcolor{keyword}{decltype}(istream) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00363}00363 \mbox{\hyperlink{namespacekblib_a8ec120cbc5e4f7c1624f07e48660b7f9}{std::getline}}(istream, str, delim);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00364}00364 \textcolor{keywordflow}{return} istream;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00365}00365 \};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00366}00366 \textcolor{keywordflow}{return} \mbox{\hyperlink{structkblib_1_1get__manip}{get\_manip}}<\textcolor{keyword}{decltype}(\_f)>\{\_f\};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00367}00367 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00368}00368 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00372}00372 \textcolor{keyword}{template} <\textcolor{keyword}{typename} F, \textcolor{keyword}{typename} CharT, \textcolor{keyword}{typename} Tr>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00373}\mbox{\hyperlink{namespacekblib_a13dd6e6d415d913d810092d9b575fd6b}{00373}} std::basic\_istream\& \mbox{\hyperlink{namespacekblib_af2086a9685efdca3d6b066f16a4fa4df}{operator>>}}(std::basic\_istream\& is,} \DoxyCodeLine{\Hypertarget{io_8h_source_l00374}00374 \mbox{\hyperlink{structkblib_1_1get__manip}{get\_manip}} func) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00375}00375 \textcolor{keywordflow}{return} func.\mbox{\hyperlink{structkblib_1_1get__manip_ad6c96adbf37dba3102defbb2ac1816f0}{\_f}}(is);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00376}00376 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00377}00377 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00381}00381 \textcolor{keyword}{template} <\textcolor{keyword}{typename} F, \textcolor{keyword}{typename} CharT, \textcolor{keyword}{typename} Tr>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00382}00382 std::basic\_ostream\& \mbox{\hyperlink{namespacekblib_a13dd6e6d415d913d810092d9b575fd6b}{operator<<}}(std::basic\_ostream\& is,} \DoxyCodeLine{\Hypertarget{io_8h_source_l00383}00383 get\_manip func) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00384}00384 \textcolor{keywordflow}{return} func.\_f(is);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00385}00385 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00386}00386 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00391}\mbox{\hyperlink{namespacekblib_1_1detail__io}{00391}} \textcolor{keyword}{namespace }\mbox{\hyperlink{namespacedetail__io}{detail\_io}} \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00392}00392 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00393}00393 \textcolor{comment}{/*}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00394}00394 \textcolor{comment}{ class steambuf\_template : public std::streambuf \{}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00395}00395 \textcolor{comment}{ protected:}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00396}00396 \textcolor{comment}{ auto imbue(const std::locale\& loc) -\/> void override;}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00397}00397 \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00398}00398 \textcolor{comment}{ auto setbuf(char\_type* s, std::streamsize n) -\/> std::streambuf* override;}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00399}00399 \textcolor{comment}{ auto seekoff(off\_type off, std::ios\_base::seekdir dir,}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00400}00400 \textcolor{comment}{ std::ios\_base::openmode which) -\/> pos\_type override; auto seekpos(pos\_type}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00401}00401 \textcolor{comment}{ pos, std::ios\_base::openmode which) -\/> pos\_type override; auto sync() -\/> int}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00402}00402 \textcolor{comment}{ override;}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00403}00403 \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00404}00404 \textcolor{comment}{ auto showmanyc() -\/> std::streamsize override;}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00405}00405 \textcolor{comment}{ auto underflow() -\/> int\_type override;}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00406}00406 \textcolor{comment}{ auto uflow() -\/> int\_type override;}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00407}00407 \textcolor{comment}{ auto xsgetn(char\_type* s, std::streamsize count) -\/> std::streamsize}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00408}00408 \textcolor{comment}{ override;}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00409}00409 \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00410}00410 \textcolor{comment}{ auto xsputn(const char\_type* s, std::streamsize count) -\/> std::streamsize}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00411}00411 \textcolor{comment}{ override; auto overflow(int\_type ch) -\/> int\_type override;}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00412}00412 \textcolor{comment}{}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00413}00413 \textcolor{comment}{ auto pbackfail(int\_type c) -\/> int\_type override;}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00414}00414 \textcolor{comment}{ \};}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00415}00415 \textcolor{comment}{ */}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00416}00416 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00417}00417 \textcolor{keyword}{template} <\textcolor{keyword}{typename} SB1\_t, \textcolor{keyword}{typename} SB2\_t>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00418}\mbox{\hyperlink{classkblib_1_1detail__io_1_1basic__teestreambuf}{00418}} \textcolor{keyword}{class }\mbox{\hyperlink{classkblib_1_1detail__io_1_1basic__teestreambuf}{basic\_teestreambuf}}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00419}00419 : \textcolor{keyword}{public} std::basic\_streambuf \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00421}00421 \textcolor{keyword}{public}:} \DoxyCodeLine{\Hypertarget{io_8h_source_l00422}\mbox{\hyperlink{classkblib_1_1detail__io_1_1basic__teestreambuf_a67a3d5c6e53d48241d07aaba98c5eb0f}{00422}} \textcolor{keyword}{using }\mbox{\hyperlink{classkblib_1_1detail__io_1_1basic__teestreambuf_a67a3d5c6e53d48241d07aaba98c5eb0f}{base\_type}} = std::basic\_streambuf<\textcolor{keyword}{typename} SB1\_t::char\_type,} \DoxyCodeLine{\Hypertarget{io_8h_source_l00423}00423 \textcolor{keyword}{typename} SB1\_t::traits\_type>;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00424}00424 \textcolor{keyword}{static\_assert}(std::is\_same<\textcolor{keyword}{typename} SB1\_t::char\_type,} \DoxyCodeLine{\Hypertarget{io_8h_source_l00425}00425 \textcolor{keyword}{typename} SB2\_t::char\_type>::value,} \DoxyCodeLine{\Hypertarget{io_8h_source_l00426}00426 \textcolor{stringliteral}{"{}Backing streams must be compatible."{}});} \DoxyCodeLine{\Hypertarget{io_8h_source_l00427}00427 \textcolor{keyword}{static\_assert}(std::is\_same<\textcolor{keyword}{typename} SB1\_t::traits\_type,} \DoxyCodeLine{\Hypertarget{io_8h_source_l00428}00428 \textcolor{keyword}{typename} SB2\_t::traits\_type>::value,} \DoxyCodeLine{\Hypertarget{io_8h_source_l00429}00429 \textcolor{stringliteral}{"{}Backing streams must be compatible."{}});} \DoxyCodeLine{\Hypertarget{io_8h_source_l00430}00430 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00431}00431 \textcolor{keyword}{using }typename base\_type::char\_type;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00432}00432 \textcolor{keyword}{using }typename base\_type::traits\_type;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00433}00433 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00434}00434 \textcolor{keyword}{using }typename base\_type::int\_type;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00435}00435 \textcolor{keyword}{using }typename base\_type::off\_type;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00436}00436 \textcolor{keyword}{using }typename base\_type::pos\_type;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00437}00437 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00438}\mbox{\hyperlink{classkblib_1_1detail__io_1_1basic__teestreambuf_a000a4a693ca6dea384231ea6a235818d}{00438}} \mbox{\hyperlink{classkblib_1_1detail__io_1_1basic__teestreambuf_a000a4a693ca6dea384231ea6a235818d}{basic\_teestreambuf}}() = \textcolor{keyword}{delete};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00439}\mbox{\hyperlink{classkblib_1_1detail__io_1_1basic__teestreambuf_a7ab743ed30dbfd4c131b9b3d2424b608}{00439}} \mbox{\hyperlink{classkblib_1_1detail__io_1_1basic__teestreambuf_a7ab743ed30dbfd4c131b9b3d2424b608}{basic\_teestreambuf}}(SB1\_t* \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}, SB2\_t* b)} \DoxyCodeLine{\Hypertarget{io_8h_source_l00440}00440 : \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}(\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}})} \DoxyCodeLine{\Hypertarget{io_8h_source_l00441}00441 , b(b) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00442}00442 this-\/>setp(\textcolor{keyword}{nullptr}, \textcolor{keyword}{nullptr});} \DoxyCodeLine{\Hypertarget{io_8h_source_l00443}00443 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00444}00444 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00445}00445 \textcolor{keyword}{private}:} \DoxyCodeLine{\Hypertarget{io_8h_source_l00446}00446 \textcolor{keyword}{auto} bool\_to\_failure(\textcolor{keywordtype}{bool} B) \textcolor{keyword}{const} \textcolor{keyword}{noexcept} -\/> int\_type \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00447}00447 \textcolor{keywordflow}{return} B ? \mbox{\hyperlink{namespacekblib_1_1detail_a837096897f96ab13aad120004c627f08}{traits\_type::to\_int\_type}}(char\_type\{\}) : \mbox{\hyperlink{namespacekblib_af23ee1a0fd16161a62159681c8cf6e16}{traits\_type::eof}}();} \DoxyCodeLine{\Hypertarget{io_8h_source_l00448}00448 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00449}00449 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00450}00450 \textcolor{keyword}{protected}:} \DoxyCodeLine{\Hypertarget{io_8h_source_l00451}\mbox{\hyperlink{classkblib_1_1detail__io_1_1basic__teestreambuf_a49a9f98425c36eb3e05eec1354b28084}{00451}} \textcolor{keyword}{auto} \mbox{\hyperlink{classkblib_1_1detail__io_1_1basic__teestreambuf_a49a9f98425c36eb3e05eec1354b28084}{imbue}}(\textcolor{keyword}{const} std::locale\& loc) -\/> \textcolor{keywordtype}{void} \textcolor{keyword}{override} \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00452}00452 \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}-\/>pubimbue(loc);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00453}00453 b-\/>pubimbue(loc);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00454}00454 \textcolor{keywordflow}{return};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00455}00455 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00456}00456 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00457}\mbox{\hyperlink{classkblib_1_1detail__io_1_1basic__teestreambuf_a3dc4be74efbbd0096b1b1b87bca46f8a}{00457}} \textcolor{keyword}{auto} \mbox{\hyperlink{classkblib_1_1detail__io_1_1basic__teestreambuf_a3dc4be74efbbd0096b1b1b87bca46f8a}{sync}}() -\/> \textcolor{keywordtype}{int} \textcolor{keyword}{override} \{ \textcolor{keywordflow}{return} \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}-\/>pubsync() | b-\/>pubsync(); \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00458}00458 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00459}\mbox{\hyperlink{classkblib_1_1detail__io_1_1basic__teestreambuf_ab7c8f00f5b750f669c72b5affe8f3e15}{00459}} \textcolor{keyword}{auto} \mbox{\hyperlink{classkblib_1_1detail__io_1_1basic__teestreambuf_ab7c8f00f5b750f669c72b5affe8f3e15}{xsputn}}(\textcolor{keyword}{const} char\_type* s, std::streamsize count)} \DoxyCodeLine{\Hypertarget{io_8h_source_l00460}00460 -\/> std::streamsize \textcolor{keyword}{override} \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00461}00461 \textcolor{keyword}{auto} a\_ct = \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}-\/>sputn(s, count);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00462}00462 \textcolor{keyword}{auto} b\_ct = b-\/>sputn(s, count);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00463}00463 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00464}00464 std::streamsize successful = \mbox{\hyperlink{namespacekblib_1_1nums_a24555c4b07301e176bf192adf4e80499}{std::min}}(a\_ct, b\_ct);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00465}00465 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00466}00466 \textcolor{keywordflow}{if} (successful == count) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00467}00467 \textcolor{keywordflow}{return} count;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00468}00468 \} \textcolor{keywordflow}{else} \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00469}00469 \textcolor{keywordflow}{return} 0;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00470}00470 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00471}00471 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00472}00472 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00473}\mbox{\hyperlink{classkblib_1_1detail__io_1_1basic__teestreambuf_a375dc5081708c30a7b04a88682c0a98c}{00473}} \textcolor{keyword}{auto} \mbox{\hyperlink{classkblib_1_1detail__io_1_1basic__teestreambuf_a375dc5081708c30a7b04a88682c0a98c}{overflow}}(int\_type ch) -\/> int\_type \textcolor{keyword}{override} \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00474}00474 \textcolor{keywordflow}{if} (not traits\_type::eq\_int\_type(ch, \mbox{\hyperlink{namespacekblib_af23ee1a0fd16161a62159681c8cf6e16}{traits\_type::eof}}())) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00475}00475 \textcolor{keyword}{auto} r\_a = \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}-\/>sputc(\mbox{\hyperlink{namespacekblib_1_1detail_a144a5c91984c56014efceb17cd66800e}{traits\_type::to\_char\_type}}(ch));} \DoxyCodeLine{\Hypertarget{io_8h_source_l00476}00476 \textcolor{keyword}{auto} r\_b = b-\/>sputc(\mbox{\hyperlink{namespacekblib_1_1detail_a144a5c91984c56014efceb17cd66800e}{traits\_type::to\_char\_type}}(ch));} \DoxyCodeLine{\Hypertarget{io_8h_source_l00477}00477 \textcolor{keywordflow}{if} (traits\_type::not\_eof(r\_a) and traits\_type::not\_eof(r\_b)) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00478}00478 \textcolor{keywordflow}{return} \mbox{\hyperlink{namespacekblib_1_1detail_a837096897f96ab13aad120004c627f08}{traits\_type::to\_int\_type}}(\{\});} \DoxyCodeLine{\Hypertarget{io_8h_source_l00479}00479 \} \textcolor{keywordflow}{else} \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00480}00480 \textcolor{keywordflow}{return} \mbox{\hyperlink{namespacekblib_af23ee1a0fd16161a62159681c8cf6e16}{traits\_type::eof}}();} \DoxyCodeLine{\Hypertarget{io_8h_source_l00481}00481 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00482}00482 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00483}00483 \textcolor{keywordflow}{return} \mbox{\hyperlink{namespacekblib_1_1detail_a837096897f96ab13aad120004c627f08}{traits\_type::to\_int\_type}}(\{\});} \DoxyCodeLine{\Hypertarget{io_8h_source_l00484}00484 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00485}00485 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00486}00486 \textcolor{keyword}{private}:} \DoxyCodeLine{\Hypertarget{io_8h_source_l00487}00487 SB1\_t* \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00488}00488 SB2\_t* b;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00489}00489 \};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00490}00490 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00491}00491 \textcolor{keyword}{template} <\textcolor{keyword}{typename} Stream>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00492}\mbox{\hyperlink{namespacekblib_1_1detail__io_ad0190242f4659f25605551c9c011c3ad}{00492}} \textcolor{keyword}{using }\mbox{\hyperlink{namespacekblib_1_1detail__io_ad0190242f4659f25605551c9c011c3ad}{buf\_for}}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00493}00493 = std::remove\_pointer\_t().rdbuf())>;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00494}00494 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00495}00495 \} \textcolor{comment}{// namespace detail\_io}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00496}00496 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00497}00497 \textcolor{keyword}{template} <\textcolor{keyword}{typename} StreamA, \textcolor{keyword}{typename} StreamB>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00498}\mbox{\hyperlink{classkblib_1_1basic__teestream}{00498}} \textcolor{keyword}{class }\mbox{\hyperlink{classkblib_1_1basic__teestream}{basic\_teestream}}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00499}00499 : \textcolor{keyword}{public} std::basic\_ostream \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00501}00501 \textcolor{keyword}{private}:} \DoxyCodeLine{\Hypertarget{io_8h_source_l00502}00502 \textcolor{keyword}{using }\mbox{\hyperlink{classkblib_1_1detail__io_1_1basic__teestreambuf}{buf\_type}} = \mbox{\hyperlink{classkblib_1_1detail__io_1_1basic__teestreambuf}{detail\_io::basic\_teestreambuf}},} \DoxyCodeLine{\Hypertarget{io_8h_source_l00503}00503 \mbox{\hyperlink{namespacekblib_1_1detail__io_ad0190242f4659f25605551c9c011c3ad}{detail\_io::buf\_for}}>;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00504}00504 \mbox{\hyperlink{classkblib_1_1detail__io_1_1basic__teestreambuf}{buf\_type}} buf;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00505}00505 \textcolor{keyword}{using }ostream\_type = std::basic\_ostream<\textcolor{keyword}{typename} StreamA::char\_type,} \DoxyCodeLine{\Hypertarget{io_8h_source_l00506}00506 \textcolor{keyword}{typename} StreamA::traits\_type>;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00507}00507 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00508}00508 \textcolor{keyword}{public}:} \DoxyCodeLine{\Hypertarget{io_8h_source_l00509}00509 \textcolor{keyword}{using }typename ostream\_type::char\_type;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00510}00510 \textcolor{keyword}{using }typename ostream\_type::traits\_type;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00511}00511 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00512}00512 \textcolor{keyword}{using }typename ostream\_type::int\_type;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00513}00513 \textcolor{keyword}{using }typename ostream\_type::off\_type;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00514}00514 \textcolor{keyword}{using }typename ostream\_type::pos\_type;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00515}00515 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00516}\mbox{\hyperlink{classkblib_1_1basic__teestream_a7f7c9026c46945088c695e250f5b9b76}{00516}} \mbox{\hyperlink{classkblib_1_1basic__teestream_a7f7c9026c46945088c695e250f5b9b76}{basic\_teestream}}(StreamA\& \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}, StreamB\& b)} \DoxyCodeLine{\Hypertarget{io_8h_source_l00517}00517 : ostream\_type(\&buf)} \DoxyCodeLine{\Hypertarget{io_8h_source_l00518}00518 , buf(\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}.rdbuf(), b.rdbuf()) \{\}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00519}00519 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00520}\mbox{\hyperlink{classkblib_1_1basic__teestream_acf48bbb7eb23439d3d1ce5fa8ca89009}{00520}} \textcolor{keyword}{auto} \mbox{\hyperlink{classkblib_1_1basic__teestream_acf48bbb7eb23439d3d1ce5fa8ca89009}{rdbuf}}() const -\/> \mbox{\hyperlink{classkblib_1_1detail__io_1_1basic__teestreambuf}{buf\_type}}* \{ \textcolor{keywordflow}{return} \&buf; \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00521}00521 \};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00522}00522 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00523}00523 \textcolor{preprocessor}{\#if 1 || KBLIB\_USE\_CXX17}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00524}00524 \textcolor{keyword}{template} <\textcolor{keyword}{typename} StreamA, \textcolor{keyword}{typename} StreamB>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00525}\mbox{\hyperlink{namespacekblib_a5731c616c6080a1e7b8f2155e76373df}{00525}} \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_a5731c616c6080a1e7b8f2155e76373df}{tee}}(StreamA\& \mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}, StreamB\& b) -\/> \mbox{\hyperlink{classkblib_1_1basic__teestream}{basic\_teestream}} \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00526}00526 \textcolor{keywordflow}{return} \{\mbox{\hyperlink{namespacekblib_a22831dce77d5f35c13930b5e30a59f07}{a}}, b\};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00527}00527 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00528}00528 \textcolor{preprocessor}{\#endif}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00529}00529 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00530}00530 \textcolor{preprocessor}{\#if KBLIB\_USE\_CXX17}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00531}00531 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00532}00532 \textcolor{keyword}{template} <\textcolor{keyword}{typename} F, \textcolor{keyword}{typename} D = std::default\_delete,} \DoxyCodeLine{\Hypertarget{io_8h_source_l00533}00533 \textcolor{keyword}{typename} P = \textcolor{keyword}{typename} D::po\textcolor{keywordtype}{int}er>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00534}\mbox{\hyperlink{structkblib_1_1file__deleter}{00534}} \textcolor{keyword}{struct }\mbox{\hyperlink{structkblib_1_1file__deleter}{file\_deleter}} \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00535}\mbox{\hyperlink{structkblib_1_1file__deleter_a9c32d5baf078533850a118c85ec70673}{00535}} std::filesystem::path \mbox{\hyperlink{structkblib_1_1file__deleter_a9c32d5baf078533850a118c85ec70673}{path}};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00536}\mbox{\hyperlink{structkblib_1_1file__deleter_a97205fcaf2a4341d62b8b1ace54bb9d4}{00536}} \textcolor{keyword}{using }\mbox{\hyperlink{structkblib_1_1file__deleter_a97205fcaf2a4341d62b8b1ace54bb9d4}{pointer}} = P;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00537}\mbox{\hyperlink{structkblib_1_1file__deleter_a8f5357f54ff38a9d8896ecb2c67c8cb3}{00537}} \textcolor{keywordtype}{void} \mbox{\hyperlink{structkblib_1_1file__deleter_a8f5357f54ff38a9d8896ecb2c67c8cb3}{operator()}}(P fs) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00538}00538 \textcolor{keyword}{static\_cast<}D\&\textcolor{keyword}{>}(\textcolor{keyword}{this})(fs);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00539}00539 std::filesystem::remove(path);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00540}00540 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00541}00541 \};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00542}00542 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00543}00543 \textcolor{preprocessor}{\# ifdef KBLIB\_POSIX\_TMPFILE}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00544}00544 \textcolor{keyword}{namespace }\mbox{\hyperlink{namespacedetail__io}{detail\_io}} \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00545}00545 \textcolor{keyword}{struct }fd\_closer \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00546}00546 \textcolor{keywordtype}{void} operator()(\textcolor{keywordtype}{int} fd) \textcolor{keyword}{const} \textcolor{keyword}{noexcept} \{ close(fd); \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00547}00547 \textcolor{keyword}{using }pointer = int;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00548}00548 \};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00549}00549 \} \textcolor{comment}{// namespace detail\_io}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00550}00550 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00551}00551 \textcolor{keyword}{using }fd\_deleter = file\_deleter;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00552}00552 \textcolor{preprocessor}{\# endif}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00553}00553 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00554}00554 \textcolor{keyword}{template} <\textcolor{keyword}{typename} File = std::fstream>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00555}\mbox{\hyperlink{namespacekblib_af0e8f19112bf1c9749dbc740205a500e}{00555}} [[nodiscard]] \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_af0e8f19112bf1c9749dbc740205a500e}{scoped\_file}}(\textcolor{keyword}{const} std::filesystem::path\& path,} \DoxyCodeLine{\Hypertarget{io_8h_source_l00556}00556 std::ios\_base::openmode mode} \DoxyCodeLine{\Hypertarget{io_8h_source_l00557}00557 = std::ios\_base::in | std::ios\_base::out) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00558}00558 \textcolor{keywordflow}{return} std::unique\_ptr>\{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00559}00559 \textcolor{keyword}{new} std::fstream\{path, mode\}, \{path\}\};} \DoxyCodeLine{\Hypertarget{io_8h_source_l00560}00560 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00561}00561 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00562}00562 \textcolor{keyword}{template} <\textcolor{keyword}{typename} File = std::fstream>} \DoxyCodeLine{\Hypertarget{io_8h_source_l00563}\mbox{\hyperlink{namespacekblib_aa2ab36dcd40fe0308a4df9359b90fb6f}{00563}} [[nodiscard]] \textcolor{keyword}{auto} \mbox{\hyperlink{namespacekblib_aa2ab36dcd40fe0308a4df9359b90fb6f}{tmpfile}}(\textcolor{keyword}{const} std::filesystem::path\& path,} \DoxyCodeLine{\Hypertarget{io_8h_source_l00564}00564 std::ios\_base::openmode mode} \DoxyCodeLine{\Hypertarget{io_8h_source_l00565}00565 = std::ios\_base::in | std::ios\_base::out) \{} \DoxyCodeLine{\Hypertarget{io_8h_source_l00566}00566 \textcolor{preprocessor}{\# ifdef KBLIB\_POSIX\_TMPFILE}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00567}00567 \textcolor{keyword}{auto} p = std::make\_unique(path, mode);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00568}00568 std::filesystem::remove(path);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00569}00569 \textcolor{keywordflow}{return} p;} \DoxyCodeLine{\Hypertarget{io_8h_source_l00570}00570 \textcolor{preprocessor}{\# else}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00571}00571 \textcolor{keywordflow}{return} scoped\_file(path, mode);} \DoxyCodeLine{\Hypertarget{io_8h_source_l00572}00572 \textcolor{preprocessor}{\# endif}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00573}00573 \}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00574}00574 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00575}00575 \textcolor{preprocessor}{\#endif}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00576}00576 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00577}00577 \} \textcolor{comment}{// namespace KBLIB\_NS}} \DoxyCodeLine{\Hypertarget{io_8h_source_l00578}00578 } \DoxyCodeLine{\Hypertarget{io_8h_source_l00579}00579 \textcolor{preprocessor}{\#endif }\textcolor{comment}{// KBLIB\_IO\_H}} \end{DoxyCode}