xparq / cstdstring Goto Github PK
View Code? Open in Web Editor NEWJoe O'Leary's excellent drop-in CString replacement, facelifted for contemporary C++
License: Other
Joe O'Leary's excellent drop-in CString replacement, facelifted for contemporary C++
License: Other
Hello
Is there a version that already support constexpr
?
I just stumbled across this. It's kind of you to bring this up to spec. I still keep my own personal version on hand that I occasionally use from time with gcc and VS2022 on W4 and Standard C++17. But I never updated my code-project article. Shame on me.
Incidentally the email address in the header file is still my current email if anyone ever needs to email me.
-Joe
I am trying to compile CStdString.h under VS2017, but I get an error.
Inside
HRESULT StreamSave(IStream* pStream) const
I have to change
else if ( empty() )
to
else if ( this->empty() )
If the formatted string is bigger than 512 characters, the Format(...) routine will leak memory on Windows Unicode builds. This is, because pBuf is not freed from the previous iteration in the following loop:
void FormatV(const CT* szFormat, va_list argList)
(...)
do
{
// Grow more than linearly (e.g. 512, 1536, 3072, etc)
nChars += ((nTry+1) * FMT_BLOCK_SIZE);
//!!alloca is unavailable/problematic in many environments:
//!! pBuf = reinterpret_cast<CT*>(_alloca(sizeof(CT)*nChars));
/***** This free() is missing *********/
if (pBuf) free(pBuf);
pBuf = reinterpret_cast<CT*>(malloc(sizeof(CT)*nChars));
if (!pBuf) throw(std::bad_alloc());
nUsed = ssvsprintf(pBuf, nChars-1, szFormat, argList);
// Ensure proper NULL termination.
nActual = nUsed == -1 ? nChars-1 : SSMIN(nUsed, nChars-1);
pBuf[nActual]= '\0';
} while ( nUsed < 0 && nTry++ < MAX_FMT_TRIES );
I am trying to compile CStdString.h under GCC 9.3.0, but I get many warnings "warning: statement has no effect [-Wunused-value]"
Changing
#define UNUSED(x) x
to
#define UNUSED(x) (void)x
removes many of them; however UNUSED() should be applied also to the various
szCvt;
empty instructions in ssadd and ssasn.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.