Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src/catch2/internal/catch_xmlwriter.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2024-09-13 11:16:20 +0200
committerMartin Hořeňovský2024-09-13 16:40:11 +0200
commit18df97df00848e91bfe1b63408bba19f8b8237ae (patch)
tree91b5056d1a6b945500c397eea60437b4a3ad79f1 /src/catch2/internal/catch_xmlwriter.cpp
parente97ebe62e700dad37fe460644e121ec462e75596 (diff)
downloadcatch3-18df97df00848e91bfe1b63408bba19f8b8237ae.tar.gz
Sprinkle some constexpr around to make Jason happy
Most of these will not matter in practice due to C++14 imposing significant limitations on what else we can make constexpr, and we cannot have references outliving the constexpr context either way.
Diffstat (limited to 'src/catch2/internal/catch_xmlwriter.cpp')
-rw-r--r--src/catch2/internal/catch_xmlwriter.cpp24
1 files changed, 2 insertions, 22 deletions
diff --git a/src/catch2/internal/catch_xmlwriter.cpp b/src/catch2/internal/catch_xmlwriter.cpp
index 6c1d45df..ccf63a56 100644
--- a/src/catch2/internal/catch_xmlwriter.cpp
+++ b/src/catch2/internal/catch_xmlwriter.cpp
@@ -53,36 +53,16 @@ namespace {
os.flags(f);
}
- bool shouldNewline(XmlFormatting fmt) {
+ constexpr bool shouldNewline(XmlFormatting fmt) {
return !!(static_cast<std::underlying_type_t<XmlFormatting>>(fmt & XmlFormatting::Newline));
}
- bool shouldIndent(XmlFormatting fmt) {
+ constexpr bool shouldIndent(XmlFormatting fmt) {
return !!(static_cast<std::underlying_type_t<XmlFormatting>>(fmt & XmlFormatting::Indent));
}
} // anonymous namespace
- XmlFormatting operator | (XmlFormatting lhs, XmlFormatting rhs) {
- return static_cast<XmlFormatting>(
- static_cast<std::underlying_type_t<XmlFormatting>>(lhs) |
- static_cast<std::underlying_type_t<XmlFormatting>>(rhs)
- );
- }
-
- XmlFormatting operator & (XmlFormatting lhs, XmlFormatting rhs) {
- return static_cast<XmlFormatting>(
- static_cast<std::underlying_type_t<XmlFormatting>>(lhs) &
- static_cast<std::underlying_type_t<XmlFormatting>>(rhs)
- );
- }
-
-
- XmlEncode::XmlEncode( StringRef str, ForWhat forWhat )
- : m_str( str ),
- m_forWhat( forWhat )
- {}
-
void XmlEncode::encodeTo( std::ostream& os ) const {
// Apostrophe escaping not necessary if we always use " to write attributes
// (see: http://www.w3.org/TR/xml/#syntax)