Skip to content

Instantly share code, notes, and snippets.

@thiagomg thiagomg/templ.cpp
Created Sep 16, 2015

What would you like to do?
Template and OO
struct string_builder {
template<typename T>
string_builder &add(T v) {
internal::add<T>(_s, v, _size);
return *this;
namespace internal {
//General implementation
template <typename T>
struct add {
add(std::string &buffer, T val, int size_inc) {
std::string s = std::to_string(val);
_check_size(buffer, s.size(), size_inc);
buffer += s;
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.