diff options
author | Abseil Team <absl-team@google.com> | 2020-11-19 14:13:24 (GMT) |
---|---|---|
committer | Gennadiy Rozental <rogeeff@google.com> | 2020-11-24 08:46:19 (GMT) |
commit | efe703618c248ecaeb07c8cd89114abb41506171 (patch) | |
tree | cb69eeb8b95f332c8e62b175a05cac559ffe06d2 /googletest/docs | |
parent | 60b8906d1452741edc060bc0001661f00aa67a7b (diff) | |
download | googletest-efe703618c248ecaeb07c8cd89114abb41506171.zip googletest-efe703618c248ecaeb07c8cd89114abb41506171.tar.gz googletest-efe703618c248ecaeb07c8cd89114abb41506171.tar.bz2 |
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.md | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/googletest/docs/faq.md b/googletest/docs/faq.md index 3ece95b..b59e1a0 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. |