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

summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMartin Hořeňovský2021-08-19 19:06:23 +0200
committerMartin Hořeňovský2021-08-19 19:15:46 +0200
commit4113a12c69809d72a3d92345ec47ccc5a0bf141c (patch)
tree0f2ab58a6690a005536ae292d2aa6fbccf9cec31
parentedad4d0af7a91693448bbf884236ea6ff2a4bd15 (diff)
downloadcatch3-4113a12c69809d72a3d92345ec47ccc5a0bf141c.tar.gz
Fix Wreserved-identifier for UDLs in Catch2
See #578
-rw-r--r--docs/contributing.md17
-rw-r--r--src/catch2/catch_approx.hpp4
-rw-r--r--src/catch2/internal/catch_stringref.hpp4
3 files changed, 21 insertions, 4 deletions
diff --git a/docs/contributing.md b/docs/contributing.md
index dc6bb537..f70b1e45 100644
--- a/docs/contributing.md
+++ b/docs/contributing.md
@@ -239,6 +239,23 @@ there is no difference is wrong, QNX and VxWorks won't compile if you
include the header as `<cfoo>` and call the function unqualified.
+#### User-Defined Literals (UDL) for Catch2' types
+
+Due to messy standardese and ... not great ... implementation of
+`-Wreserved-identifier` in Clang, avoid declaring UDLs as
+```cpp
+Approx operator "" _a(long double);
+```
+and instead declare them as
+```cpp
+Approx operator ""_a(long double);
+```
+
+Notice that the second version does not have a space between the `""` and
+the literal suffix.
+
+
+
### New source file template
If you are adding new source file, there is a template you should use.
diff --git a/src/catch2/catch_approx.hpp b/src/catch2/catch_approx.hpp
index 74833494..8f0e6327 100644
--- a/src/catch2/catch_approx.hpp
+++ b/src/catch2/catch_approx.hpp
@@ -114,8 +114,8 @@ namespace Catch {
};
namespace literals {
- Approx operator "" _a(long double val);
- Approx operator "" _a(unsigned long long val);
+ Approx operator ""_a(long double val);
+ Approx operator ""_a(unsigned long long val);
} // end namespace literals
template<>
diff --git a/src/catch2/internal/catch_stringref.hpp b/src/catch2/internal/catch_stringref.hpp
index fed35b16..17f5d07d 100644
--- a/src/catch2/internal/catch_stringref.hpp
+++ b/src/catch2/internal/catch_stringref.hpp
@@ -98,12 +98,12 @@ namespace Catch {
};
- constexpr auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef {
+ constexpr auto operator ""_sr( char const* rawChars, std::size_t size ) noexcept -> StringRef {
return StringRef( rawChars, size );
}
} // namespace Catch
-constexpr auto operator "" _catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef {
+constexpr auto operator ""_catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef {
return Catch::StringRef( rawChars, size );
}