utf8_lookup, a write up.

I saw this blog post a while ago A Programmer’s Introduction to Unicode, a really great write up that is a worth a read for anyone interested in the subject! So go ahead and read that now even as it might not be super important for what I am about to write about here :)

Reading this reminded me of an old project of mine that I think is a bit novel and deserves, at least, a write up. I am talking about utf8_lookup, a small lib to translate utf8 chars into offsets into a table.

Read More

Why I prefer inline forward-declares in C++

Time for a short post on how I usually do the humble forward declare in C++. I guess this is not something new but it is something I usually do not see in others code so it feels worth sharing.

So lets start of with just defining what we are talking about just to get everyone on the same page, we are talking about declaring only a class/struct name to the compiler and not having to provide the entire class/struct declaration. Mostly used as a compile-time optimization or to handle circular deps etc.

Read More

Compile-time hashes in c++, im not convinced!

I recently read a blogpost about compile-time string-hashes and constexpr and I’m still not convinced and see no real reason to leave my old and true friend the script :)

So first of lets look at the problem we want to solve. We want a way to do things like this and not pay the runtime cost ( and in this case just compile! ).

void my_func( uint32_t val )
{
    switch( val )
    {
        case HashOfString("some_string"):
            do_some_stuff();
            break;
        case HashOfString("some_other_string"):
            do_some_other_stuff();
            break;
    }
}

      Read More