C++

warning: Creating default object from empty value in /mnt/web005/a1/00/51694400/htdocs/bwy/public_html/sites/all/modules/i18n/i18ntaxonomy/i18ntaxonomy.pages.inc on line 34.
Über die Programmiersprache C++, den Standard, oder die Boost-C++-Bibliotheken.

Boost Program Options accumulator type

After various requests, I've licensed my boost program_options extension code accumulator.hpp under the Boost Software License 1.0. It also now supports taking an argument on construction to store the value as well as the notifier function.

To recap: the accumulator type adds support for repeated options used to increment a particular value. Often this is used for verbosity, so that -v sets a verbosity level of one, -vvv a level of three.

Weekend adventures in noise

Perlin noise in Gnash

My graphic design skills are poor, a fact all the more frustrating because I have a good enough eye to recognize when something looks bad, but not the aptitude to improve it.

Unlike less restrained people, I haven't inflicted the unreadable crimes of Word Art on my fellow humans since I was a teenager (though as previous work on implementing gradients for the MovieClip drawing API shows, when you have an excuse, playing with garish gradients is still fun!). But along with other design-incompetents, I'm fascinated by adventurous graphics and patterns.

Most concise C++ FizzBuzz

What is the most concise C++ FizzBuzz?

The following code appears initially to be a pretty good candidate:

#include <iostream>
#include <ostream>

using std::cout;

int main()
{
    for (int i=0;i++<100;)
        (!(i%3)&&cout<<"Fizz")|(!(i%5)&&cout<<"Buzz")||cout<<i,cout<<"\n";
}

Boost Program Options

Boost's program_options library does a lot of things (such as formatting help messages and adding default values) automatically, and it means different program modules can add and handle their own options. This is exactly what we need it for.

Its main disadvantage is incomplete documentation. There are some common command-line behaviours that aren't built in, which is fine as long as they can be added. And indeed program_options is fairly extensible and flexible, which in turn is fine as long as you have documentation to tell you how to do it.

Gnash optimization

Gnash has recently been benefiting from some performance enhancements.

Sandro Santilli started profiling ActionScript execution and noticed some serious bottlenecks in the way Gnash handles property identifiers.

Gnash under Clang

Gnash is now completely compilable and optimizable with the LLVM frontend Clang. The AGG renderer headers have one C++ bug that causes an error. This needs to be fixed externally if you want to use that renderer, as it seems legitimate for a compiler to reject it (even if GCC doesn't).

Clang has already helped to find a few bugs in Gnash. Some warnings picked up things that GCC missed. And most interestingly, there were cases where Gnash's behaviour was relying on the order of evaluating function arguments.

C++ ASCII literals

I didn't invent it! But as I can't find the original code, here is my own version. The idea was most likely inspired by the somewhat cleverer, but no more useful analogue literals.

Create your own ASCII art, drawing it directly in the source code. Can you think of anything more beautiful?!

#include <iostream>
#include <string>
#include <algorithm>
#include <iterator>

struct AsciiLiteral
{
    AsciiLiteral() : n(false) {}

C++ facets

Facets are one of the least understood and most esoteric parts of the C++ standard library. Because they are rarely used, there are few code examples, which in turn means most people never encounter them.

This is a great shame! Facets are a fascinating and multifa rich source of coding fun!

Pointers and recursive templates

How do you get the 'pointed-to' type in C++?

template<typename T>
struct RemovePointer
{
    typedef T value_type;
};

template<typename T>
struct RemovePointer<T*>
{
    typedef typename RemovePointer<T>::value_type value_type;
};

What's the point? With a bit of boost magic, you can use pointers transparently in generic code:

Inhalt abgleichen