diff options
author | George L. Albany <Megacake1234@gmail.com> | 2023-09-02 14:31:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-02 14:31:44 +0200 |
commit | f990117e56060811ddd2a850ec712485aea79649 (patch) | |
tree | 2bb062c320fa2227b18956617b94d0e8800420d8 /src/openvic-dataloader/detail/NullBuff.hpp | |
parent | e941573f47fb867ff75c8a2cf78302b754ffbeee (diff) | |
parent | 7440a5d1433eec4bf87e3723022db187e7f61b1a (diff) |
Merge pull request #7 from OpenVicProject/dataloading-event-and-functions
Diffstat (limited to 'src/openvic-dataloader/detail/NullBuff.hpp')
-rw-r--r-- | src/openvic-dataloader/detail/NullBuff.hpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/openvic-dataloader/detail/NullBuff.hpp b/src/openvic-dataloader/detail/NullBuff.hpp new file mode 100644 index 0000000..baf9e1b --- /dev/null +++ b/src/openvic-dataloader/detail/NullBuff.hpp @@ -0,0 +1,30 @@ +#pragma once + +#include <ostream> + +namespace ovdl::detail { + template<class cT, class traits = std::char_traits<cT>> + class basic_nullbuf : public std::basic_streambuf<cT, traits> { + typename traits::int_type overflow(typename traits::int_type c) { + return traits::not_eof(c); // indicate success + } + }; + + template<class cT, class traits = std::char_traits<cT>> + class basic_onullstream : public std::basic_ostream<cT, traits> { + public: + basic_onullstream() : std::basic_ios<cT, traits>(&m_sbuf), + std::basic_ostream<cT, traits>(&m_sbuf) { + std::basic_ios<cT, traits>::init(&m_sbuf); + } + + private: + basic_nullbuf<cT, traits> m_sbuf; + }; + + typedef basic_onullstream<char> onullstream; + typedef basic_onullstream<wchar_t> wonullstream; + + inline onullstream cnull; + inline onullstream wcnull; +}
\ No newline at end of file |