2017

Emulating reflection proposals May 07, 2017

Despite this year is being far less productive than I expected (Well, that’s not fair, past year I used to work from 09:00 to 18:00 + 3h of commuting, then play with C++ from 22:00 to 02:00-06:00 depending on the day. I was so exhausted by the end of the year I decided to slow down my C++ fever a bit), I’m still throwing commits from time to time towards the refactorization of siplasplas (See...

Lock-free job stealing with modern c++ March 13, 2017

In my previous post I (re)introduced you to my main personal project, siplasplas, a library and tool to implement static and dynamic reflection with C++14. Also runtime C++ compilation on top of it, I’m a bit masochist… As I told in the intro of my previous post, after Meeting C++ conference my main work has been to port the reflection parser from Python to a reusable C++ API. One of the core aspects of the...

Writing AST matchers for libclang February 11, 2017

Preface It has been like one year or so since the last time I wrote a blog post. I used to habve that common habit of writing posts about the latest supposedly cool thing I’ve been working on. But this has been a weird year which I’ve spent leaving my CS degree (Why is a matter for another post…), working hard both at work, and at home with my latest-but-yet-wip project: siplasplas Siplasplas started as...

2016

Objects anywhere, anytime April 17, 2016

A long time ago, in a post far far away… we seen how constexpr can be used to retrieve and store type names at compile time, so C++ types can be tagged and indexed without relying on RTTI. The goal of this series is to build a simple reflection engine. Since the engine is dynamic, we need a way to handle objects of heterogenous types at runtime. A kind of Boost.Any, but focused on our...

A new hope April 01, 2016

As you may already know, last C++ standarization committee meeting in Jacksonville decided what items will be part of the C++17 standard, what other will be Technical Specifications, and want others were rejected at all. I had a lot of hope in C++17. A lot new of cool features, Concepts, Modules, Coroutines; were promised to us. But nothing was approved. This is no longer a major release but a minor one. Also, WTF is a...

The road for reflection: Tagging types March 13, 2016

Something like a month ago I wrote a post introducting the reflection engine I’m writing as part of a C++ course for people in the game programming master degree of my university. Why me, an undergrad that has the end of his CS grade faaaaaaar away from his horizon, is giving such a course is a mater of another post (A post on “Why I hate the university sooooooo much“…). Writing a reflection engine has...

C++11 Opaque Pointer Idiom March 07, 2016

This was originally a wiki entry I was writing for the By Tech internal development wiki this morning, but I thought it’s the kind of simple and useful tip that deserves a blog post… Opaque Pointer (PIMPL) Idiom The opaque pointer idiom provides a way to isolate the implementation of a class from its interface, by forwarding interface calls to a private type (The implementation) that’s declared as part of class definition: class MyClass {...

Reflection (Intro) January 30, 2016

For three years I have been giving some C++ courses in my university as part of my spare time (Aka “the time I should have been studing”…), most of them focused in getting C++ right from the beginning. This year I decided to split the course in two: One for beginners (The usual course I give) and an advanced C++ course focused at people in the game programming master degree. For them “advanced C++” means...

2015

Bitchunks August 24, 2015

I would have liked to talk about Concepts Lite, but I’m still working on contiguous integration support for the examples I want to share. Maybe in a couple of weeks. Today I will talk about a simple data structure, what I call “bitchunks”. std::bitset The C++ Standard Library ships with a template called std::bitset, which represents fixed-size sequences of bits. It works great for bit twiddling, giving a clean and sane “container like” interface instead...

User Friendly C++14 Concepts August 01, 2015

Before the acceptance of Concepts Lite TS into C++17, there was a lot of effort out there in the community to make a C++11/14 compatible implementation of Concepts, at least an emulation wrapping the usual SFINAE tricks. Concepts provide nice syntax for concept definition type constraining. No more SFINAE! (I hope). This will make C++ syntax clean in one of the very few points I think C++ still needs a “lifting”: templates. Concepts Lite also...

Resurce Handlers and Value Semantics June 30, 2015

Before C++11, implementing correct value semantics for a class was a complete pain: You must deal with the constructor, copy constructor, (copy) assignment operator, and then the destructor. Also you had to take some care since those semantics are tightly coupled between that special member functions, so the compiler may reject to provide a default implementation for any of these if you break the semantics of at least one. As you might know, this rule...

RAII for API, Naked Ptrs for Internals? June 27, 2015

It’s well stablished that having raw pointers as part of a C++ API is not a good practice since it’s not clear who (The user or the API internals) manages the resource. Consider: namespace int_buff { int* factory(); void have_fun(int*); } Let’s say you have an API that operates on int buffers. The first function, factory(), returns a new buffer ready to play with. The latter have_fun() does something with a buffer. When reading such...

Foldie June 23, 2015

I find C++ template metaprogramming so funny. Maybe it’s the feel of being hacking the compiler, maybe is just a way to improve my functional programming skills. I’m not sure. But the fact is that I do meta on C++ a lot, and I’m actually used to the way it works and its idiosyncrasies. In this crazy story, to run the metaprogram becomes to compile the c++ program and then see the results. This means...

Haskellizing C++ template metaprogramming March 19, 2015

If you followed my crazy tales about the Haskell Metaphor you may think I have a great problem with myself and the way I waste my free time… I have been doing intensive C++ template metaprogramming for up to three years, developing my own tmp library called Turbo, with the idea of providing high-level facilities for C++ metaprogramming. You all know, the syntax is horrible, the compiler error messages are not better. But there’s still...

2014

High Level Template Metaprogramming, Step by Step: Simple Expressions October 27, 2014

I you are one of who have been following our post series about template metaprogramming with modern C++, at this time you should have become a C++ template Guru. At least thats what I expect ;). You know about class templates, function templates, value parameters, type parameters, variadic templates… Your template metaprogramming toolbox is full of great things to play with. Thats good, but you want to start playing with your compiler, writting some cool...

I Hate the Switch Statement October 19, 2014

C++ inherits many of its features from the C programming language, some of them fit well with modern programming, and some others do not. One cathegory of such features is the syntax for flow control, where the C language stands above the rest of the languages thanks to some constructions able to do almost any trick you can ever imagine. Look at the for loop: Is not a simple three arguments construction. You can do...