Get rid of the iostream include in bt::string

This commit is contained in:
King_DuckZ 2022-05-24 16:35:16 +02:00
parent b0422b73d6
commit 742271ad09
2 changed files with 12 additions and 1 deletions

View file

@ -21,6 +21,7 @@
#include <chrono> #include <chrono>
#include <thread> #include <thread>
#include <unistd.h> #include <unistd.h>
#include <iostream>
#if defined(__GNU_LIBRARY__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 17) || __GLIBC__ > 2) #if defined(__GNU_LIBRARY__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 17) || __GLIBC__ > 2)
# define HasSecureGetenv # define HasSecureGetenv

View file

@ -18,9 +18,13 @@
#ifndef id170B0E6C34D14EBA9B92A35977BDBFB3 #ifndef id170B0E6C34D14EBA9B92A35977BDBFB3
#define id170B0E6C34D14EBA9B92A35977BDBFB3 #define id170B0E6C34D14EBA9B92A35977BDBFB3
//#define PRINTABLE_STRING_BT
#include <utility> #include <utility>
#include <cstddef> #include <cstddef>
#if defined(PRINTABLE_STRING_BT)
# include <iostream> # include <iostream>
#endif
#include <stdexcept> #include <stdexcept>
namespace dhandy { namespace dhandy {
@ -28,8 +32,10 @@ namespace dhandy {
template <std::size_t S, typename Ch=char> template <std::size_t S, typename Ch=char>
class string; class string;
#if defined(PRINTABLE_STRING_BT)
template <std::size_t S, typename Ch> template <std::size_t S, typename Ch>
std::basic_ostream<Ch>& operator<< ( std::basic_ostream<Ch>& parStream, const string<S, Ch>& parString ); std::basic_ostream<Ch>& operator<< ( std::basic_ostream<Ch>& parStream, const string<S, Ch>& parString );
#endif
namespace implem { namespace implem {
template <std::size_t S, typename Ch> constexpr bool eq (const string<S, Ch>& l, const string<S, Ch>& r); template <std::size_t S, typename Ch> constexpr bool eq (const string<S, Ch>& l, const string<S, Ch>& r);
@ -37,7 +43,9 @@ namespace dhandy {
template <std::size_t S, typename Ch> template <std::size_t S, typename Ch>
class string { class string {
#if defined(PRINTABLE_STRING_BT)
friend std::ostream& operator<< <>( std::ostream& parStream, const string<S>& parString ); friend std::ostream& operator<< <>( std::ostream& parStream, const string<S>& parString );
#endif
friend constexpr bool implem::eq<S, Ch> (const string<S, Ch>&, const string<S, Ch>&); friend constexpr bool implem::eq<S, Ch> (const string<S, Ch>&, const string<S, Ch>&);
public: public:
using value_type = Ch; using value_type = Ch;
@ -122,11 +130,13 @@ namespace dhandy {
return implem::concat(std::make_index_sequence<S + S2 - 1>(), string<S>(m_data), parOther); return implem::concat(std::make_index_sequence<S + S2 - 1>(), string<S>(m_data), parOther);
} }
#if defined(PRINTABLE_STRING_BT)
template <std::size_t S, typename Ch> template <std::size_t S, typename Ch>
inline std::ostream& operator<< (std::ostream& parStream, const string<S, Ch>& parString) { inline std::ostream& operator<< (std::ostream& parStream, const string<S, Ch>& parString) {
parStream << parString.m_data; parStream << parString.m_data;
return parStream; return parStream;
} }
#endif
template <std::size_t S, typename Ch> template <std::size_t S, typename Ch>
constexpr bool string<S, Ch>::operator== (const string<S, Ch>& other) const { constexpr bool string<S, Ch>::operator== (const string<S, Ch>& other) const {