Fix ::sapi:✌️:Char::ToString()

Also make it correct with scoped enums.

PiperOrigin-RevId: 422310326
Change-Id: Ie2db81ec7c8d8ecd8d5fb79573bc9f5040fd8c3b
This commit is contained in:
Wiktor Garbacz 2022-01-17 02:04:26 -08:00 committed by Copybara-Service
parent 9229b3fa82
commit a339850dbf

View File

@ -16,10 +16,10 @@
#define SANDBOXED_API_VAR_REG_H_
#include <iostream>
#include <string>
#include <type_traits>
#include <glog/logging.h>
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "sandboxed_api/var_abstract.h"
@ -113,8 +113,11 @@ std::string Reg<T>::GetTypeString() const {
template <typename T>
std::string Reg<T>::ToString() const {
if constexpr (std::is_integral_v<T> || std::is_enum_v<T>) {
return absl::StrCat(value_);
if constexpr (std::is_integral_v<T>) {
return std::to_string(value_);
}
if constexpr (std::is_enum_v<T>) {
return std::to_string(static_cast<std::underlying_type_t<T>>(value_));
}
if constexpr (std::is_floating_point_v<T>) {
return absl::StrFormat("%.10f", value_);