mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-18 17:45:48 +00:00
Add safe_cast (RIPD-1702):
This change ensures that no overflow can occur when casting between enums and integral types.
This commit is contained in:
committed by
Nik Bougalis
parent
494724578a
commit
148bbf4e8f
@@ -20,6 +20,7 @@
|
||||
#ifndef RIPPLE_PROTOCOL_TER_H_INCLUDED
|
||||
#define RIPPLE_PROTOCOL_TER_H_INCLUDED
|
||||
|
||||
#include <ripple/basics/safe_cast.h>
|
||||
#include <ripple/json/json_value.h>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
@@ -270,22 +271,22 @@ enum TECcodes : TERUnderlyingType
|
||||
|
||||
// For generic purposes, a free function that returns the value of a TE*codes.
|
||||
constexpr TERUnderlyingType TERtoInt (TELcodes v)
|
||||
{ return static_cast<TERUnderlyingType>(v); }
|
||||
{ return safe_cast<TERUnderlyingType>(v); }
|
||||
|
||||
constexpr TERUnderlyingType TERtoInt (TEMcodes v)
|
||||
{ return static_cast<TERUnderlyingType>(v); }
|
||||
{ return safe_cast<TERUnderlyingType>(v); }
|
||||
|
||||
constexpr TERUnderlyingType TERtoInt (TEFcodes v)
|
||||
{ return static_cast<TERUnderlyingType>(v); }
|
||||
{ return safe_cast<TERUnderlyingType>(v); }
|
||||
|
||||
constexpr TERUnderlyingType TERtoInt (TERcodes v)
|
||||
{ return static_cast<TERUnderlyingType>(v); }
|
||||
{ return safe_cast<TERUnderlyingType>(v); }
|
||||
|
||||
constexpr TERUnderlyingType TERtoInt (TEScodes v)
|
||||
{ return static_cast<TERUnderlyingType>(v); }
|
||||
{ return safe_cast<TERUnderlyingType>(v); }
|
||||
|
||||
constexpr TERUnderlyingType TERtoInt (TECcodes v)
|
||||
{ return static_cast<TERUnderlyingType>(v); }
|
||||
{ return safe_cast<TERUnderlyingType>(v); }
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Template class that is specific to selected ranges of error codes. The
|
||||
|
||||
Reference in New Issue
Block a user