C++ Literals

Da Andreabont's Wiki.

Codice

#include <iostream>
#include <sstream>

std::string operator"" _double (const char* str, size_t len) {
        std::stringstream ss;
        for (int i = 0; i < len*2; i++) {
                ss << str[i%len];
        }
        return ss.str();
}

int main() {
        std::cout << "ciao"_double << std::endl; // Stampa "ciaociao"
}