//This file is offset. #ifndef TERMINAL_TRAITSH #define TERMINAL_TRAITSH #include //for ostream #include //for rand #include using namespace std; template class terminal_traits { public: typedef typename CONTAINER::difference_type offset_type; static offset_type rand() {return std::rand() % 3 - 1;} static offset_type signum(offset_type off) {return off < 0 ? -1 : off > 0;} typedef pair key_t; typedef map keypad_t; static keypad_t keypad(); friend ostream& operator<<(ostream& ost, const key_t& key) { return ost << "('" << key.first << "', " << key.second << ")"; } }; template typename terminal_traits::keypad_t terminal_traits::keypad() { #ifdef _MSC_VER keypad_t k; k.insert(key_t('h', -1)); //left k.insert(key_t('l', 1)); //right return k; #else static const key_t a[] = { key_t('h', -1), //left key_t('l', 1) //right }; static const size_t n = sizeof a / sizeof a[0]; return keypad_t(a, a + n); #endif } template inline typename CONTAINER::value_type background(const CONTAINER&) { return ' '; } #endif