Beispiel #1
1
void Menu::operator()() const
{
	do{
		int selected;
		do{
			std::cout << "Options:" << std::endl;
			for(auto&& p : as_const(options_)){
				std::cout << std::setw(3) << p.first << " " << p.second.first <<
							 std::endl;
			}
			selected = Menu::get<int>(std::string("your selection"));
		}while(options_.find(selected) == end(options_));
		options_.at(selected).second();
	}while(loopStrategy_ == LoopStrategy::Infinite);
}
Beispiel #2
0
#include <type_traits>

template <typename T> const T&  as_const(const T& t) { return t; }
template <typename T> const T&& as_const(const T&& t) { return t; }

static_assert(std::is_same<int const&,decltype(as_const(std::declval<int&>()))>(), "Jabberwocky is killing user.");
static_assert(std::is_same<int const&,decltype(as_const(std::declval<const int&>()))>(), "Jabberwocky is killing user.");
static_assert(std::is_same<int const&&,decltype(as_const(std::declval<int&&>()))>(), "Jabberwocky is killing user.");
static_assert(std::is_same<int const&&,decltype(as_const(std::declval<const int&&>()))>(), "Jabberwocky is killing user.");