Boost logo

Boost :

Subject: Re: [boost] [system][filesystem v3] Question about error_code arguments
From: Scott McMurray ([hidden])
Date: 2009-10-20 12:07:40

2009/10/20 Beman Dawes <bdawes_at_[hidden]>:
> Regardless, I'd like to hear Boosters views on the two interfaces
> above. Which do you prefer? Why?

Since it's neither polymorphic nor ownership-transferring, I really
dislike the pointer version.

Now, I have no idea how error_code is specified, but I thought it
would have been something like this, which wouldn't require null

struct error_code {
    static const int throw_instead = ~0;
    error_code(int c = 0) : code_(c) {}
    int code() const { return code_; }
    error_code &operator=(int c) {
        if (code_ == throw_instead) throw system_exception(c);
        code_ = c;
        return *this;
    int code_;

error_code throws_object(error_code::throw_instead);
error_code &throws() { return throws_object; }

That said, I'd much prefer the pointer version to anything that
requires that implementation code check whether the address of a
reference is null, despite my distaste at having to pass &error all
over the place.

~ Scott

Boost list run by bdawes at, gregod at, cpdaniel at, john at