mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 19:02:04 +00:00
4e76629aaf
- lots of static_cast - add safe_cast - types adjustments - config - IStorage::read/watch - ... - some TODO's (to convert types in future) P.S. That was quite a journey... v2: fixes after rebase v3: fix conflicts after #42308 merged Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
23 lines
382 B
C++
23 lines
382 B
C++
#pragma once
|
|
|
|
#include <Common/Exception.h>
|
|
|
|
namespace DB
|
|
{
|
|
|
|
namespace ErrorCodes
|
|
{
|
|
extern const int LOGICAL_ERROR;
|
|
}
|
|
|
|
template <class To, class From>
|
|
To safe_cast(From from)
|
|
{
|
|
constexpr auto max = std::numeric_limits<To>::max();
|
|
if (from > max)
|
|
throw Exception(ErrorCodes::LOGICAL_ERROR, "Overflow ({} > {})", from, max);
|
|
return static_cast<To>(from);
|
|
}
|
|
|
|
}
|