nr-maybe.h revision a4030d5ca449e7e384bc699cd249ee704faaeab0
#ifndef __NR_MAYBE_H__
#define __NR_MAYBE_H__
/*
* Nullable values for C++
*
* Copyright 2004, 2007 MenTaLguY <mental@rydia.net>
*
* This code is licensed under the GNU GPL; see COPYING for more information.
*/
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdexcept>
#include <string>
#include <algorithm>
};
struct Nothing {};
MaybeStorage() : _is_nothing(true) {}
MaybeStorage(T const &value)
bool is_nothing() const { return _is_nothing; }
T _value;
bool _is_nothing;
};
Maybe() {}
if (m) {
_storage = *m;
}
}
if (m) {
_storage = *m;
}
}
if (_storage.is_nothing()) {
} else {
}
}
if (_storage.is_nothing()) {
} else {
}
}
if (_storage.is_nothing()) {
} else {
}
}
if (_storage.is_nothing()) {
} else {
}
}
if ( is_nothing || !other ) {
return is_nothing && !other;
} else {
}
}
if ( is_nothing || !other ) {
return !is_nothing || other;
} else {
}
}
MaybeStorage<T> _storage;
};
if (m) {
_ref = &*m;
}
}
if (m) {
_ref = *m;
}
}
if (m) {
_ref = *m;
}
}
if (!_ref) {
} else {
return *_ref;
}
}
if (!_ref) {
} else {
return _ref;
}
}
} else {
}
}
} else {
}
}
T *_ref;
};
} /* namespace NR */
#endif
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :