diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2022-06-14 14:54:27 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2022-06-14 21:07:47 +0100 |
commit | 1b65779f46f16b4fffd0591f5e58722c1e7cde8d (patch) | |
tree | c366f92a62fb159b814f0c254df0f0f8a1ad0847 /libstdc++-v3/testsuite | |
parent | 29da01709facbcc7efef4fd6767660d417f44531 (diff) |
libstdc++: Inline all basic_string::compare overloads [PR59048]
Defining the compare member functions inline allows calls to
traits_type::length and std::min to be inlined, taking advantage of
constant expression arguments. When not inline, the compiler prefers to
use the explicit instantiation definitions in libstdc++.so and can't
take advantage of constant arguments.
libstdc++-v3/ChangeLog:
PR libstdc++/59048
* include/bits/basic_string.h (compare): Define inline.
* include/bits/basic_string.tcc (compare): Remove out-of-line
definitions.
* include/bits/cow_string.h (compare): Define inline.
* testsuite/21_strings/basic_string/operations/compare/char/3.cc:
New test.
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r-- | libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/char/3.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/char/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/char/3.cc new file mode 100644 index 00000000000..8d2917c5145 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/operations/compare/char/3.cc @@ -0,0 +1,7 @@ +// { dg-options "-O1 -g0" } +// { dg-do compile } +// { dg-final { scan-assembler-not "12basic_stringIcSt11char_traitsIcESaIcEE7compare" } } + +#include <string> +bool eq() { return std::string("blah") == "literal"; } +bool lt() { return std::string("blah") < "literal"; } |