[wpilib] Make Color::HexString() constexpr (#5985)

Related improvements to wpi::ct_string:
* Implicitly convert to std::string
* Add operator== for std::string, std::string_view, and const Char*
This commit is contained in:
Tyler Veness
2023-12-04 21:20:49 -08:00
committed by GitHub
parent 2676b77873
commit 90757b9e90
7 changed files with 105 additions and 36 deletions

View File

@@ -1,13 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "frc/util/Color.h"
using namespace frc;
std::string Color::HexString() const {
return fmt::format("#{:02X}{:02X}{:02X}", static_cast<int>(255.0 * red),
static_cast<int>(255.0 * green),
static_cast<int>(255.0 * blue));
}

View File

@@ -1,11 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "frc/util/Color8Bit.h"
using namespace frc;
std::string Color8Bit::HexString() const {
return fmt::format("#{:02X}{:02X}{:02X}", red, green, blue);
}