You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by GitBox <gi...@apache.org> on 2020/09/09 03:34:51 UTC

[GitHub] [incubator-brpc] mapleFU opened a new issue #1238: Make StringPiece match std::string_view

mapleFU opened a new issue #1238:
URL: https://github.com/apache/incubator-brpc/issues/1238


   **Is your feature request related to a problem? (你需要的功能是否与某个问题有关?)**
   
   C++17 will include `std::string_view`, which is essentially just a standardized replacement for StringPiece. To plan ahead for this, we should consider updating the StringPiece API so that it exactly matches std::string_view. Then a few years from now when C++17 is widespread we can make StringPiece just a type alias for std::string_view. I believe StringPiece is just used within protobuf internals at the moment and so we can safely change its API without breaking any user code.
   
   **Describe the solution you'd like (描述你期望的解决方法)**
   
   Using a macro to using string_view
   
   ```
   #ifdef XXX
   using base = basic_string_view
   ...
   #else 
   // The original definitions..
   #endif
   ```
   
   The abseil and boost solve it in this way.
   
   **Describe alternatives you've considered (描述你想到的折衷方案)**
   
   Using constructor like `StringPiece(string_view)`...
   
   **Additional context/screenshots (更多上下文/截图)**
   
   None.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] mapleFU commented on issue #1238: Make StringPiece match std::string_view

Posted by GitBox <gi...@apache.org>.
mapleFU commented on issue #1238:
URL: https://github.com/apache/incubator-brpc/issues/1238#issuecomment-689370848


   @gydong Since I'm a butil user, I may need to cast string_view to StringPiece, and maybe I can make it more convient(


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] pleiadesian commented on issue #1238: Make StringPiece match std::string_view

Posted by GitBox <gi...@apache.org>.
pleiadesian commented on issue #1238:
URL: https://github.com/apache/incubator-brpc/issues/1238#issuecomment-832674705


   It seems to be hard to make the StringPiece API exactly matches std::string_view. There are many methods in StringPiece that do not exist in std::string_view, such as `trim_spaces`, `front_or_0`, `wordmemcmp` and `CopyToString`. 
   There are two possible ways to solve this issue:
   1. Change these unmatching methods to functions and modify all the callers to use these functions. 
   2. Extend the std::string_view with the unmatching methods after c++17 is introduced by brpc.
   Any suggestions? @gydong 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] gydong commented on issue #1238: Make StringPiece match std::string_view

Posted by GitBox <gi...@apache.org>.
gydong commented on issue #1238:
URL: https://github.com/apache/incubator-brpc/issues/1238#issuecomment-689907098


   u are welcome to do that


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] mapleFU commented on issue #1238: Make StringPiece match std::string_view

Posted by GitBox <gi...@apache.org>.
mapleFU commented on issue #1238:
URL: https://github.com/apache/incubator-brpc/issues/1238#issuecomment-689408886


   Maybe I can support this, would you mind me support string_view?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org


[GitHub] [incubator-brpc] gydong commented on issue #1238: Make StringPiece match std::string_view

Posted by GitBox <gi...@apache.org>.
gydong commented on issue #1238:
URL: https://github.com/apache/incubator-brpc/issues/1238#issuecomment-689345797


   Yes, we can do this. But, what are the benifits for users since StringPiece is only used in brpc framework and users can use std::string_view themselves.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org