WTF does WTF represent in the WebKit code base?

C++WebkitChromium

C++ Problem Overview


I downloaded Chromium's code base and ran across the WTF namespace.

namespace WTF {
    /*
     * C++'s idea of a reinterpret_cast lacks sufficient cojones.
     */
    template<typename TO, typename FROM>
    TO bitwise_cast(FROM in)
    {
        COMPILE_ASSERT(sizeof(TO) == sizeof(FROM), WTF_wtf_reinterpret_cast_sizeof_types_is_equal);
        union {
            FROM from;
            TO to;
        } u;
        u.from = in;
        return u.to;
    }
} // namespace WTF

Does this mean what I think it means? Could be so, the bitwise_cast implementation specified here will not compile if either TO or FROM is not a POD and is not (AFAIK) more powerful than C++ built in reinterpret_cast.

The only point of light I see here is the nobody seems to be using bitwise_cast in the Chromium project.

C++ Solutions


Solution 1 - C++

It’s short for Web Template Framework and provides commonly used functions all over the WebKit codebase.

Solution 2 - C++

Solution 3 - C++

> Could be so, the bitwise_cast implementation specified here yields undefined behaviour if either TO or FROM is not a POD

If FROM or TO are not POD types, the compilation would fail with current C++ standard because you wouldn't be able to put them in union.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMottiView Question on Stackoverflow
Solution 1 - C++ismailView Answer on Stackoverflow
Solution 2 - C++StanView Answer on Stackoverflow
Solution 3 - C++ArtyomView Answer on Stackoverflow