Hey, C++ programmers, stop writing Strict Weak Orderings by hand for your classes.
For two members it's manageable:
bool operator<(const Widget& l, const Widget& r)
{
if (l.x < r.x)
return true;
if (r.x < l.x)
return false;
return l.y < r.y;
}
bool operator<(const Widget& l, const Widget& r)
{
if (l.x < r.x)
return true;
if (r.x < l.x)
return false;
if (l.y < r.y)
return true;
if (r.y < l.y)
return false;
return l.z < r.z;
}
bool operator<(const Widget& l, const Widget& r)
{
return l.x < r.x ? true : r.x < l.x ? false : l.y < r.y ? true : r.y < l.y ? false : l.z < r.z;
}
bool operator<(const Widget& l, const Widget& r)
{
return l.x < r.x || (!(r.x < l.x) && (l.y < r.y || (!(r.y < l.y) && l.z < r.z)));
}
bool operator<(const Widget& l, const Widget& r)
{
return std::tie(l.x, l.y, l.z) < std::tie(r.x, r.y, r.z);
}
tie
function template, and even PHP programmers could do that.#include <boost/tuple/tuple_comparison.hpp>
and then use boost::tie
instead of std::tie
.Gah, stupid brain. I need to remember that the modified pattern space after a series of sed commands will only be printed and deleted right away if that modified pattern space doesn't match the addresses of any later commands. If it does match, it might get further modified and then not printed. Stick ;p;d
after the series of commands to avoid that, and not spend an hour scratching your head.
In more interesting news, I've been having fun with new Fedora releases. I upgraded my desktop to F17, because it's not possible to upgrade straight to F18 from F16, but once there I found it so miraculously beefy I decided to keep it. On x86_64 F18 doesn't offer me much that isn't in F17, and what I really want is glibc 2.17 which includes the most excellent change I asked for, but isn't in F18. Following the advice of freenode's #fedora-devel I've got a mock
chroot where I can use rawhide, so that I can make some changes to libstdc++ so that a high-resolution std::system_clock
will be enabled by default on systems using glibc 2.17+
I have, however, installed F18 (beta) on the shiny ARM chromebook I got for xmas, thanks to lots of help from #fedora-arm. That's a huge improvement on my ageing eeepc netbook. Kudos to the Fedora ARM team on excellent work.
I've also got round to sending my paperwork to the FSF so I can contribute to GDB, which means I should resume working on my patch to teach GDB about C++11 rvalue references. That's been on hold while I sat on the paperwork, wrote a C++ standard proposal and started work on my talk for this year's ACCU conference. (If my wife wasn't working so hard on her studies she'd probably be asking me to stop all these extracurricular activites by now!)
I've often joked that instead of picking up Djikstra's cute acronym we should have called the basic synchronization object "the bottleneck". Bottlenecks are useful at times, sometimes indispensible -- but they're never GOOD.
Gold linker + CentOS5 NFS client + Solaris 10 NFSd = ballache
I've spent a day and a half being completely bewildered by a weird NFS bug where ELF binaries (but not other files) written to an NFS mount show up on remote hosts with the correct file size but consisting entirely of nul zero bytes, but only when written from CentOS5 hosts, not from Solaris, Fedora or RHEL6 hosts.
I eventually narrowed it down to the Gold linker, which writes files using mmap
, and the CentOS5 2.6.18 kernel has a bug when writing files with mmap
to NFS mounts.
There was a very similar RHEL4 bug that should be fixed in my kernel, but for some reason the kernel-2.6.18-redhat.patch
file in the SRPM comments out the fix. I don't know why.
Maybe this post will show up for anyone else searching for the symptoms, because I didn't have much luck searching the web for it.
My solution is to avoid Gold on CentOS5 (since we can't easily stop using NFS, unfortunately) but I wish I could get that day of my life back.
Update: The distcc
FAQ (search for Files written to NFS filesystems are corrupt) mentions this problem and refers to a post to the distcc list and a post to the linux-nfs list where a workaround using the no_subtree_check
option for nfsd is given, but that assumes the NFS server is linux, and mine isn't
Wishbone and the Illustrated Classics series have gotten me through every conversation I've ever had about Dickens, Treasure Island, The Anarchist's Cookbook, and Our Bodies, Ourselves.
-- Randall Munroe
"Well, the feature was in the language so I figured I
should use it.". It is our belief that this is not a
sufficient criteria for using a feature of C++. A feature
should be used only when it can be demonstrated to be
of benefit. A mountain is climbed "because it is there".
The same should not hold true for C++ features. Their
mere existence is not justification for use.
Andy Smith, an internet security chief at the Cabinet Office, said people should only give accurate details to trusted sites such as government ones.He said names and addresses posted on social networking sites "can be used against you" by criminals.
His advice was described by Labour MP Helen Goodman as "totally outrageous".
Ms Goodman, shadow culture minister, told BBC News: "This is the kind of behaviour that, in the end, promotes crime.
"It is exactly what we don't want. We want more security online. It's anonymity which facilitates cyber-bullying, the abuse of children."
Recently I've had time to work on some C++11 library additions for libstdc++ which had been brewing in my Git tree for months. std::forward_list
meets the C++11 allocator container requirements now. std::scoped_allocator_adaptor
is 99% complete now. I'm trying to provide std::this_thread::yield()
, std::this_thread::sleep_*()
and a high-resolution std::system_clock
even when GCC isn't built with --enable-libstdcxx-time (with huge thanks to Roland McGrath for help from glibc.) I need to write tests for my implementations of std::wstring_convert
and std::wbuffer_convert
so I can commit them.
Some stuff I've looked at today:
Mirage, a good reason to learn OCaml.
Parallela, a supercomputer for everyone.
From a few entries down on Advogato's recentlog: the Ada Initiative is running a fundraising campaign, you should donate.
New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.
Keep up with the latest Advogato features by reading the Advogato status blog.
If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!