Custom minimal stream - verifies that template_streamop works with non-std streams
| 55 | |
| 56 | // Custom minimal stream - verifies that template_streamop works with non-std streams |
| 57 | class MinimalStream { |
| 58 | private: |
| 59 | std::string buf_; |
| 60 | public: |
| 61 | MinimalStream& operator<<(const std::string& s) { buf_ += s; return *this; } |
| 62 | MinimalStream& operator<<(const char* s) { buf_ += s; return *this; } |
| 63 | MinimalStream& operator<<(char c) { buf_ += c; return *this; } |
| 64 | MinimalStream& operator<<(int32_t i) { buf_ += std::to_string(i); return *this; } |
| 65 | MinimalStream& operator<<(int64_t i) { buf_ += std::to_string(i); return *this; } |
| 66 | MinimalStream& operator<<(uint32_t i) { buf_ += std::to_string(i); return *this; } |
| 67 | MinimalStream& operator<<(uint64_t i) { buf_ += std::to_string(i); return *this; } |
| 68 | MinimalStream& operator<<(double d) { |
| 69 | char tmp[64]; |
| 70 | std::snprintf(tmp, sizeof(tmp), "%g", d); |
| 71 | buf_ += tmp; |
| 72 | return *this; |
| 73 | } |
| 74 | MinimalStream& operator<<(bool b) { buf_ += (b ? "true" : "false"); return *this; } |
| 75 | const std::string& str() const { return buf_; } |
| 76 | }; |
| 77 | |
| 78 | int main() { |
| 79 | std::cout << "Testing private_optional + template_streamop combined..." << std::endl; |
nothing calls this directly
no test coverage detected