Created
January 20, 2016 13:41
-
-
Save bagobor/c17228c05ee20ffbd7cb to your computer and use it in GitHub Desktop.
std::streambuff derived class for mem optimisations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class carray_streambuf : public std::streambuf { | |
public: | |
carray_streambuf(char *data, unsigned int len) { | |
setp(data, data+len); | |
setg(data, data, data + len); | |
} | |
// amount of stored (written!) data in bytes | |
size_t saved_bytes() const { return pptr() - pbase(); } | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment