/usr/include/wibble/mixin.h is in libwibble-dev 0.1.28-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | // -*- C++ -*- (c) 2007 Peter Rockai <me@mornfall.net>
#ifndef WIBBLE_MIXIN_H
#define WIBBLE_MIXIN_H
#include <cstddef>
#include <bits/stl_iterator_base_types.h>
namespace wibble {
namespace mixin {
template< typename Self >
struct Comparable {
const Self &cmpSelf() const {
return *static_cast< const Self * >( this );
}
bool operator!=( const Self &o ) const {
return not( cmpSelf() == o );
}
bool operator==( const Self &o ) const {
return cmpSelf() <= o && o <= cmpSelf();
}
bool operator<( const Self &o ) const {
return cmpSelf() <= o && cmpSelf() != o;
}
bool operator>( const Self &o ) const {
return o <= cmpSelf() && cmpSelf() != o;
}
bool operator>=( const Self &o ) const {
return o <= cmpSelf();
}
// you implement this one in your class
// bool operator<=( const Self &o ) const { return this <= &o; }
};
/**
* Mixin with output iterator paperwork.
*
* To make an output iterator, one just needs to inherit from this
* template and implement Self& operator=(const WhaToAccept&)
*/
template< typename Self >
struct OutputIterator :
public std::iterator<std::output_iterator_tag, void, void, void, void>
{
Self& operator++() {
return *static_cast<Self*>(this);
}
Self operator++(int)
{
Self res = *static_cast<Self*>(this);
++*this;
return res;
}
Self& operator*() {
return *static_cast<Self*>(this);
}
};
}
}
#endif
|