Skip to content
Snippets Groups Projects
Commit 0d9f81f7 authored by yang-g's avatar yang-g
Browse files

minor fixes

parent 967caaad
No related branches found
No related tags found
No related merge requests found
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
* *
*/ */
#ifndef GRPCXX_STRING_REF_H #ifndef GRPCXX_SUPPORT_STRING_REF_H
#define GRPCXX_STRING_REF_H #define GRPCXX_SUPPORT_STRING_REF_H
#include <iterator> #include <iterator>
#include <iosfwd> #include <iosfwd>
...@@ -44,6 +44,8 @@ namespace grpc { ...@@ -44,6 +44,8 @@ namespace grpc {
// This class is a non owning reference to a string. // This class is a non owning reference to a string.
// It should be a strict subset of the upcoming std::string_ref. See: // 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 // 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 { class string_ref {
public: public:
// types // types
...@@ -115,6 +117,4 @@ std::ostream& operator<<(std::ostream& stream, const string_ref& string); ...@@ -115,6 +117,4 @@ std::ostream& operator<<(std::ostream& stream, const string_ref& string);
} // namespace grpc } // namespace grpc
#endif // GRPCXX_STRING_REF_H #endif // GRPCXX_SUPPORT_STRING_REF_H
...@@ -80,7 +80,7 @@ size_t string_ref::find(string_ref s) const { ...@@ -80,7 +80,7 @@ size_t string_ref::find(string_ref s) const {
} }
size_t string_ref::find(char c) 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); return it == cend() ? npos : std::distance(cbegin(), it);
} }
......
...@@ -100,8 +100,8 @@ TEST_F(StringRefTest, Assignment) { ...@@ -100,8 +100,8 @@ TEST_F(StringRefTest, Assignment) {
TEST_F(StringRefTest, Iterator) { TEST_F(StringRefTest, Iterator) {
string_ref s(kTestString); string_ref s(kTestString);
size_t i = 0; size_t i = 0;
for (char c : s) { for (auto it = s.cbegin(); it != s.cend(); ++it) {
EXPECT_EQ(kTestString[i++], c); EXPECT_EQ(kTestString[i++], *it);
} }
EXPECT_EQ(strlen(kTestString), i); EXPECT_EQ(strlen(kTestString), i);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment