Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login


For every problem there is one solution which is simple, neat, and wrong. -- H. L. Mencken

devel / comp.lang.c++ / Pure beauty

o Pure beautyBonita Montero

Pure beauty


  copy mid

  copy link   Newsgroups: comp.lang.c++
From: (Bonita Montero)
Newsgroups: comp.lang.c++
Subject: Pure beauty
Date: Thu, 31 Aug 2023 20:59:05 +0200
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <ucqnto$3df6a$>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 31 Aug 2023 18:59:04 -0000 (UTC)
Injection-Info:; posting-host="ff70a7335e595a5f320387c3a69d8d92";
logging-data="3587274"; mail-complaints-to=""; posting-account="U2FsdGVkX19BpqJmPXzvGDnsepwdsNmYwG7/BIZez4g="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:2+QzyAFvEw5YLG5/t9bSoJSZBfs=
Content-Language: de-DE
 by: Bonita Montero - Thu, 31 Aug 2023 18:59 UTC

I wrote a small Win32 tool that combines time from Unix, start
from Windows and runas from Windows in one. For this I just needed
a function that processes the number of clock cycles spent by the
process into a string. I wanted to use iterator debugging as much
as possible so that the whole thing is as good as safe from out
-of-bound errors. Here is the function:

string formatClockCycles( uint64_t clockCycles, char separator )
{ char digits[32];
auto [end, ec] = to_chars( digits, std::end( digits ), clockCycles );
string_view svDigits( digits, end );
size_t dots = (svDigits.length() - 1) / 3;
string_view::iterator itDigits = svDigits.end();
string dottified;
dottified.resize( svDigits.length() + dots, '*' );
string::iterator itRet = dottified.end();
for( ; dots--; itDigits -= 3, itRet -= 4 )
copy( itDigits - 3, itDigits, itRet - 3 ),
itRet[-4] = separator;
copy( svDigits.begin(), itDigits, dottified.begin() );
return dottified;

devel / comp.lang.c++ / Pure beauty


rocksolid light 0.9.81
clearnet tor