Add Input Helper
This commit is contained in:
@@ -0,0 +1 @@
|
||||
#include "inputHelper.h"
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
Author: Joel Mathew Thomas
|
||||
Date: 18-02-2026
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace util
|
||||
{
|
||||
template <typename T>
|
||||
void readValue(T& value)
|
||||
{
|
||||
std::cin >> value;
|
||||
if (std::cin.fail())
|
||||
{
|
||||
std::cin.clear();
|
||||
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
|
||||
throw std::runtime_error("Invalid Console Input");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user