You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "James E. King, III (JIRA)" <ji...@apache.org> on 2016/01/04 18:57:39 UTC
[jira] [Comment Edited] (THRIFT-3513)
lib/cpp/src/thrift/TToString.h : the function "to_string" is not compatible
for int8_t(byte)
[ https://issues.apache.org/jira/browse/THRIFT-3513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15081476#comment-15081476 ]
James E. King, III edited comment on THRIFT-3513 at 1/4/16 5:56 PM:
--------------------------------------------------------------------
I assume this is the result of looking at:
http://www.boost.org/doc/libs/1_60_0/doc/html/boost_lexical_cast/frequently_asked_questions.html
In addition, given int8_t is the C++ emitted type to store a thrift "byte", it might be more appropriate for the output to be hexadecimal, for example a byte containing 'K' could be output as "0x4B" or "0x4b". The proposed change would output a byte containing 'K' as the number 75. The original code should output the character 'K'.
I'm not sure I would consider this a bug at all, but if we were going to change it I would opt to use a 0x%02X printf notation.
was (Author: jking3):
I assume this is the result of looking at:
http://www.boost.org/doc/libs/1_60_0/doc/html/boost_lexical_cast/frequently_asked_questions.html
In addition, given int8_t is the C++ emitted type to store a thrift "byte", it might be more appropriate for the output to be hexadecimal, for example a byte containing 'K' could be output as "0x4B" or "0x4b". The proposed change would output a byte containing 'K' as the number 75. The original code should output the character 'K'.
I'm not sure I would consider this a bug at all.
> lib/cpp/src/thrift/TToString.h : the function "to_string" is not compatible for int8_t(byte)
> --------------------------------------------------------------------------------------------
>
> Key: THRIFT-3513
> URL: https://issues.apache.org/jira/browse/THRIFT-3513
> Project: Thrift
> Issue Type: Bug
> Components: C++ - Library
> Affects Versions: 0.9.3
> Environment: centos6.4 , x84_64 , g++ 4.4.7
> Reporter: phoneli
> Priority: Trivial
>
> In Source Code " lib/cpp/src/thrift/TToString.h " ,
> lines between 34~37 :
> template <typename T>
> std::string to_string(const T& t) {
> return boost::lexical_cast<std::string>(t);
> }
> the function "to_string" is not compatible for int8_t(byte) when using std::cout or printf
> The Codes should change like this :
> template <typename T>
> std::string to_string(const T& t) {
> return boost::lexical_cast<std::string>(t);
> }
> std::string to_string(const int_8 & t) {
> return boost::lexical_cast<std::string>(static_cast<int>(t));
> }
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)