am going crazy, or bug cygwin g++ compiler?
this works:
std::string record; record += (uint8_t)1;
it totally cool appending const variable value 0:
const uint8_t tzero = 0x00; std::string record; record += tzero;
however, running code causes ambiguous operator overload error:
std::string record; record += (uint8_t)0;
the candidates provides make no sense given explicit cast, since 1 of candidates seems identical given in error:
sources/logger.cpp:55:20: error: ambiguous overload `operator+=' (operand types `std::string {aka std::basic_string<char>}' , `uint8_t {aka unsigned char}') record += (const uint8_t)0; note: candidates: operator+=(const basic_string& __str) operator+=(const _chart* __s) operator+=(_chart __c)
this error not appear in visual studio, compiles , appends 0x00 byte expect.
for reference, i'm using strings buffers binary log data. there's better container use, being able += bytes in useful not have.
does cygwin have bug string implementation, or supposed cause error since it's 0? don't mind using const variable fix error, weird since process repeated multiple times through code other values.
this recent change c++ language. nowadays, code should call operator+=(_chart)
. in past, code should fail due ambiguity const uint8_t tzero = 0x00;
. you're dealing compiler that's partially implemented change.
before change language, integer constant expression value of 0 implicitly convertible pointer type , yielded null pointer. that's why (uint8_t)0
converted char
, or const char *
.
now, literal 0
can converted pointer types. tzero
, or (uint8_t)0
, should no longer convert const char *
. resolves ambiguity: conversion char
still remains possibility.
Comments
Post a Comment