He's not dead, he's resting

Making Paludis Compile with C++0x

I managed to get gcc 4.4 svn to compile, so I decided to see just how badly the experimental C++0x support would break Paludis. Turns out, not too badly. Firstly, things caught by increased strictness or general rearrangement of headers:

  • We had a few extra semicolons lying around. These now generate warnings, so we might as well shut them up. [fix]
  • We weren’t including <stdint.h> to get uintptr_t. Things were working by fluke because other headers were including it. [fix]
  • We were using ::rename rather than std::rename. [fix]

Then, the real issues:

  • n2246 adds a std::next. Paludis has a paludis::next. ADL means this sometimes causes confusion. To keep compatibility with non-0x compilers, we use using to get std::next into paludis:: where necessary. [fix]
  • std::list<>::push_back is now overloaded on rvalue references, so we can no longer easily get a PMF. If we were only interested in 0x, we’d use a lambda, but for backwards compatibility we write a wrapper function instead. (Or we could use the static_cast hack, but that’s horribly unreadable.) [fix]

All in all, not too bad. I suspect things will get a bit messier if a concept-enabled standard library makes it into the final proposal, but that can be dealt with later…


One response to “Making Paludis Compile with C++0x

  1. pizer March 30, 2009 at 8:32 pm

    Regarding overloaded member functions and mem_fn: You can specify the function’s signature as a template parameter:

    mem_fn<void(int const&)>(&….)

    but then you have the problem that the real parameter type might actually be “int” instead of “int const&” for std::list<int>::push_back. I’m not sure whether the standard mandates “int const&” here.

    You might also want to consider std::back_inserter from the <iterator> header.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s