From 5e4181da4f2ad9b272adbe2bb4a83da6d9d38ac8 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 2 May 2022 07:20:00 +0300 Subject: Autocommit at 02.05.2022 @ 07:20 --- src/ConsoleInterface/Menu.cpp | 2 +- src/ConsoleInterface/Toolbox.cpp | 5 +++++ src/ConsoleInterface/Toolbox.h | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/ConsoleInterface') diff --git a/src/ConsoleInterface/Menu.cpp b/src/ConsoleInterface/Menu.cpp index f12dbf2..7bd7c5e 100644 --- a/src/ConsoleInterface/Menu.cpp +++ b/src/ConsoleInterface/Menu.cpp @@ -20,7 +20,7 @@ void Menu::navigate() const { print("Execute No [1-"); print(menuOptions.get_count()); print("]: "); - std::cin >> buffer; + read(buffer); } menuOptions[buffer - 1].run(); diff --git a/src/ConsoleInterface/Toolbox.cpp b/src/ConsoleInterface/Toolbox.cpp index ccab1b7..c42e0b2 100644 --- a/src/ConsoleInterface/Toolbox.cpp +++ b/src/ConsoleInterface/Toolbox.cpp @@ -6,6 +6,11 @@ void read(T* storage) { std::cin >> storage; } +template +void read(T& storage) { + std::cin >> storage; +} + template void print(const T* item) { std::cout << item; diff --git a/src/ConsoleInterface/Toolbox.h b/src/ConsoleInterface/Toolbox.h index cf2434e..8d13537 100644 --- a/src/ConsoleInterface/Toolbox.h +++ b/src/ConsoleInterface/Toolbox.h @@ -2,7 +2,10 @@ #define HEADER_CONSOLEINTERFACE_TOOLBOX template -void read(T* storage) { +void read(T* storage); + +template +void read(T& storage); template void print(const T* item); -- cgit v1.3.1-23-gd82d