summaryrefslogtreecommitdiff
path: root/googletest/docs
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2020-11-19 09:13:24 -0500
committerGennadiy Rozental <rogeeff@google.com>2020-11-24 03:46:19 -0500
commitefe703618c248ecaeb07c8cd89114abb41506171 (patch)
treecb69eeb8b95f332c8e62b175a05cac559ffe06d2 /googletest/docs
parent60b8906d1452741edc060bc0001661f00aa67a7b (diff)
downloadgoogletest-git-efe703618c248ecaeb07c8cd89114abb41506171.tar.gz
Googletest export
Update note on static const data members for C++17. Using `constexpr` provides a tidier solution, where applicable. PiperOrigin-RevId: 343276402
Diffstat (limited to 'googletest/docs')
-rw-r--r--googletest/docs/faq.md12
1 files changed, 12 insertions, 0 deletions
diff --git a/googletest/docs/faq.md b/googletest/docs/faq.md
index 3ece95bc..b59e1a0d 100644
--- a/googletest/docs/faq.md
+++ b/googletest/docs/faq.md
@@ -217,6 +217,18 @@ particular, using it in googletest comparison assertions (`EXPECT_EQ`, etc) will
generate an "undefined reference" linker error. The fact that "it used to work"
doesn't mean it's valid. It just means that you were lucky. :-)
+If the declaration of the static data member is `constexpr` then it is
+implicitly an `inline` definition, and a separate definition in `foo.cc` is not
+needed:
+
+```c++
+// foo.h
+class Foo {
+ ...
+ static constexpr int kBar = 100; // Defines kBar, no need to do it in foo.cc.
+};
+```
+
## Can I derive a test fixture from another?
Yes.