Anton Dolganin

I'm an engineer focused on solving problems, not tied to any specific language. Architecture, development, DevOps โ€” I choose the right tools for the job and build solutions that work in production and scale without pain.

C++ allows you to define custom suffixes like _km, _kg, _usd using operator"". This improves readability and enables compile-time conversions.

Example โ€” converting kilometers and meters:

constexpr long double operator"" _km(long double val) {
    return val * 1000;
}
constexpr long double operator"" _m(long double val) {
    return val;
}
int main() {
    long double distance = 2.5_km + 300.0_m;
    std::cout << distance << " meters\n"; // 2800 meters
}

You can define literals for numeric types, strings, std::chrono, and more.

User-defined literals in C++ โ€” readable, expressive, and compile-time