/usr/include/osl/player.h is in libosl-dev 0.6.0-3.3.
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 73 | #ifndef OSL_PLAYER_H
#define OSL_PLAYER_H
#include <boost/static_assert.hpp>
#include <cassert>
#include <iosfwd>
namespace osl{
enum Player{
BLACK=0,
WHITE= -1
};
inline Player alt(Player player){
return static_cast<Player>(-1-static_cast<int>(player));
}
inline int playerToIndex(Player player){
return -static_cast<int>(player);
}
inline Player indexToPlayer(int n) {
assert(n == 0 || n == 1);
return static_cast<Player>(-n);
}
inline int playerToMul(Player player){
int ret=1+(static_cast<int>(player)<<1);
assert(ret==1 || ret== -1);
return ret;
}
inline int playerToSign(Player player)
{
return playerToMul(player);
}
inline int playerToMask(Player player){
return static_cast<int>(player);
}
// These codes are intentionally DECLARED and NOT IMPLEMENTED.
// you will get link error here if you write code such as "value += v * piece.owner() == BLACK ? 1.0 : -1.0;"
int operator+(Player, int); int operator+(int, Player);
int operator-(Player, int); int operator-(int, Player);
int operator*(Player, int); int operator*(int, Player);
int operator/(Player, int); int operator/(int, Player);
/**
* cast等で作られたplayerが正しいかどうかを返す
*/
bool isValid(Player player);
template<Player P>
struct PlayerTraits;
template<>
struct PlayerTraits<BLACK>{
static const int offsetMul=1;
static const int index=0;
static const int mask=0;
static const Player opponent=WHITE;
};
template<>
struct PlayerTraits<WHITE>{
static const int offsetMul=-1;
static const int index=1;
static const int mask= -1;
static const Player opponent=BLACK;
};
std::ostream& operator<<(std::ostream& os,Player player);
}
#endif /* OSL_PLAYER_H */
// ;;; Local Variables:
// ;;; mode:c++
// ;;; c-basic-offset:2
// ;;; coding:utf-8
// ;;; End:
|