/usr/include/kashmir/randomstream.h is in libkashmir-dev 0.0~git20150805.0.2f3913f+dfsg3-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 | // randomstream.h -- random number stream
// Copyright (C) 2008 Kenneth Laskoski
/** @file randomstream.h
@brief random number stream
@author Copyright (C) 2008 Kenneth Laskoski
*/
#ifndef KL_RANDOMSTREAM_H
#define KL_RANDOMSTREAM_H
#include <cstddef>
namespace kashmir {
// CRTP stands for curiously recurring template pattern
template<class crtp_impl>
class randomstream
{
crtp_impl *const self;
public:
randomstream<crtp_impl>() : self(static_cast<crtp_impl*>(this)) {}
void read(char *buffer, std::size_t count)
{
self->read(buffer, count);
}
randomstream<crtp_impl>& operator>>(char& c) { read(&c, 1); return *this; }
randomstream<crtp_impl>& operator>>(signed char& c) { read(reinterpret_cast<char*>(&c), 1); return *this; }
randomstream<crtp_impl>& operator>>(unsigned char& c) { read(reinterpret_cast<char*>(&c), 1); return *this; }
randomstream<crtp_impl>& operator>>(int& n) { read(reinterpret_cast<char*>(&n), sizeof(int)); return *this; }
randomstream<crtp_impl>& operator>>(long& n) { read(reinterpret_cast<char*>(&n), sizeof(long)); return *this; }
randomstream<crtp_impl>& operator>>(short& n) { read(reinterpret_cast<char*>(&n), sizeof(short)); return *this; }
randomstream<crtp_impl>& operator>>(unsigned int& u) { read(reinterpret_cast<char*>(&u), sizeof(unsigned int)); return *this; }
randomstream<crtp_impl>& operator>>(unsigned long& u) { read(reinterpret_cast<char*>(&u), sizeof(unsigned long)); return *this; }
randomstream<crtp_impl>& operator>>(unsigned short& u) { read(reinterpret_cast<char*>(&u), sizeof(unsigned short)); return *this; }
randomstream<crtp_impl>& operator>>(float& f) { read(reinterpret_cast<char*>(&f), sizeof(float)); return *this; }
randomstream<crtp_impl>& operator>>(double& f) { read(reinterpret_cast<char*>(&f), sizeof(double)); return *this; }
randomstream<crtp_impl>& operator>>(long double& f) { read(reinterpret_cast<char*>(&f), sizeof(long double)); return *this; }
randomstream<crtp_impl>& operator>>(bool& b) { read(reinterpret_cast<char*>(&b), sizeof(bool)); b &= 1; return *this; }
randomstream<crtp_impl>& operator>>(void*& p) { read(reinterpret_cast<char*>(&p), sizeof(void*)); return *this; }
};
} // namespace kashmir
#endif
|