News for hackers. Stuff that matters.
Re:Ill-Advised C++ Rant, Part 2 (2016) by DerekL on Wednesday October 25, 2017 @08:59PM (#15555553)
You can use user-defined literals for a portable way to write four-character codes:

    constexpr std::uint32_t operator "" _4CC(const char* str, size_t len) {
        std::uint32_t result = 0;
        for (size_t i = 0; i < len; ++i) {
            result = (result << 8) + (std::uint32_t)(unsigned char)(str[i]);
        }
        return result;
    }

    auto const movie = "MooV"_4CC;

There are no comments on this comment yet.