diff options
author | 2015-08-26 22:27:02 -0700 | |
---|---|---|
committer | 2015-08-26 22:27:02 -0700 | |
commit | 15df9b1357b763b126efb0b8735557e816598946 (patch) | |
tree | 8396780e126a8db360700b182ed2722eef2527a9 | |
parent | 967caaada09ab68acb6242311549012f1a07bbff (diff) | |
parent | 0d9f81f741b33e23941db435b9ba7a9ed37adaec (diff) |
Merge pull request #3094 from yang-g/string_ref_auth
minor fixes to string_ref
-rw-r--r-- | include/grpc++/support/string_ref.h | 10 | ||||
-rw-r--r-- | src/cpp/util/string_ref.cc | 2 | ||||
-rw-r--r-- | test/cpp/util/string_ref_test.cc | 4 |
3 files changed, 8 insertions, 8 deletions
diff --git a/include/grpc++/support/string_ref.h b/include/grpc++/support/string_ref.h index fd2b3ad8e7..2bc1fecefe 100644 --- a/include/grpc++/support/string_ref.h +++ b/include/grpc++/support/string_ref.h @@ -31,8 +31,8 @@ * */ -#ifndef GRPCXX_STRING_REF_H -#define GRPCXX_STRING_REF_H +#ifndef GRPCXX_SUPPORT_STRING_REF_H +#define GRPCXX_SUPPORT_STRING_REF_H #include <iterator> #include <iosfwd> @@ -44,6 +44,8 @@ namespace grpc { // This class is a non owning reference to a string. // It should be a strict subset of the upcoming std::string_ref. See: // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3442.html +// The constexpr is dropped or replaced with const for legacy compiler +// compatibility. class string_ref { public: // types @@ -115,6 +117,4 @@ std::ostream& operator<<(std::ostream& stream, const string_ref& string); } // namespace grpc -#endif // GRPCXX_STRING_REF_H - - +#endif // GRPCXX_SUPPORT_STRING_REF_H diff --git a/src/cpp/util/string_ref.cc b/src/cpp/util/string_ref.cc index eb54f65e3a..9adc092013 100644 --- a/src/cpp/util/string_ref.cc +++ b/src/cpp/util/string_ref.cc @@ -80,7 +80,7 @@ size_t string_ref::find(string_ref s) const { } size_t string_ref::find(char c) const { - auto it = std::find_if(cbegin(), cend(), [c](char cc) { return cc == c; }); + auto it = std::find(cbegin(), cend(), c); return it == cend() ? npos : std::distance(cbegin(), it); } diff --git a/test/cpp/util/string_ref_test.cc b/test/cpp/util/string_ref_test.cc index c4ca4fce84..465072d43e 100644 --- a/test/cpp/util/string_ref_test.cc +++ b/test/cpp/util/string_ref_test.cc @@ -100,8 +100,8 @@ TEST_F(StringRefTest, Assignment) { TEST_F(StringRefTest, Iterator) { string_ref s(kTestString); size_t i = 0; - for (char c : s) { - EXPECT_EQ(kTestString[i++], c); + for (auto it = s.cbegin(); it != s.cend(); ++it) { + EXPECT_EQ(kTestString[i++], *it); } EXPECT_EQ(strlen(kTestString), i); } |