Add Input Helper

This commit is contained in:
Joel Thomas
2026-02-18 18:37:48 +05:30
parent 1785aefe52
commit 22a146a560
2 changed files with 24 additions and 0 deletions
@@ -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");
}
}
}