Skip to content

Instantly share code, notes, and snippets.

@thiagomg thiagomg/templ.cpp
Last active Sep 16, 2015

What would you like to do?
Template and OO - Custom class
//Now I can add my own class to this string_builder add function
struct LazyMessage {
std::string type;
int seq;
std::vector<std::string> entries;
namespace Text {
namespace internal {
template <>
struct add<LazyMessage> {
add(std::string &buffer, LazyMessage &msg, int size_inc) {
std::string s = msg.type;
for(const auto &entry : msg.entries)
s += " [" + entry + "]";
_check_size(buffer, s.size(), size_inc);
buffer += s;
} //Namespace internal
} //Namespace Text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.