Sunday, November 22, 2015

Digest for comp.lang.c++@googlegroups.com - 12 updates in 3 topics

Rosario19 <Ros@invalid.invalid>: Nov 22 09:41AM +0100

On Sat, 14 Nov 2015 12:20:41 +0100, Rosario19 wrote:
 
>lines of w lenght
>words max lenght w-1, if word lenght >= w-1 break the word in 2 pieces
>using one "-" in between
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
 
#define u32 unsigned
#define i32 int
#define u8 unsigned char
 
#define R return
#define P printf
#define F for
#define GG(a,b) if(a)goto b
#define G goto
 
i32 WrdLetter(i32 a){R isalpha(a);}
 
// Programma per rompere le linee secondo argomento
int main(int c, char** a)
{u8 *buf=0;
u32 w, i, j, iWrd;
i32 k, r, v;
 
if( c>1&&a[1]&&isdigit((u8) a[1][0]) )
w=atoi(a[1]);
else w=80;
if(w<1||w>0xFFF0)
{P("Argument number out of range:\n");
l0: P("Usage: thisProg number <filein >fileout\n");
P("Usage: thisProg <filein >fileout\n Number=80\n");
l1: free(buf);
R 1; // wrong
}
buf=(u8*) malloc(w+8);
if(buf==0){P("Memory insufficient\n"); G l0;}
F(i=0, iWrd=0; ; )
{k=getchar();
if(k==EOF||!(v=WrdLetter(k))) // EOF or ERROR or not alpha
{if(iWrd){//Svuota buffer word;
svuotaBuf: if( (iWrd+i)>w ) // aaaa==4
{P("\n"); i=0;}
F(j=0; j<iWrd; ++j)
{r=putchar(buf[j]); ++i;
GG(r==EOF, l1);
if(i>=w-1&&v)
{P("-\n"); i=0;}
}
iWrd=0;
}
}
GG(k==EOF,l3); // exit ok
if(v){// scrivi nel buffer
GG(iWrd>=w-1, svuotaBuf);
buf[iWrd++]=(u8)k;
}
else {// scrivi nel output
if(i>=w)
{if(k!='\n') P("\n");
i=0;
}
r=putchar(k);
++i;
if(k=='\n') i=0;
GG(r==EOF, l1);
}
}
l3:
GG( ferror(stdin)||ferror(stdout), l1);
free(buf);
R 0; //ok
}
Melzzzzz <mel@zzzzz.com>: Nov 22 09:57AM +0100

On Sun, 22 Nov 2015 09:41:43 +0100
> #define F for
> #define GG(a,b) if(a)goto b
> #define G goto
./..,
 
What an ugly piece of crap !
Rosario19 <Ros@invalid.invalid>: Nov 22 09:59AM +0100

On Sun, 22 Nov 2015 09:57:02 +0100, Melzzzzz wrote:
>> #define G goto
>./..,
 
>What an ugly piece of crap !
 
it is the crap that run ok
Vir Campestris <vir.campestris@invalid.invalid>: Nov 22 09:16PM

On 22/11/2015 08:59, Rosario19 wrote:
>> ./..,
 
>> What an ugly piece of crap !
 
> it is the crap that run ok
 
It's still ugly. And it doesn't look like C++.
 
Andy
Lynn McGuire <lmc@winsim.com>: Nov 21 09:55PM -0600

On 11/20/2015 7:24 PM, Victor Bazarov wrote:
>> have this now.
 
> Why do you think you need this?
 
> V
 
We have different behavior based on the name of the class. We do have a
Class::className method in all of our classes, I was just wondering if
we could forgo that now. I forget why, but virtualization does not work
in this particular case other than to supply the name of the class.
 
Thanks,
Lynn
Lynn McGuire <lmc@winsim.com>: Nov 21 09:55PM -0600

On 11/21/2015 2:50 PM, Öö Tiib wrote:
> badly standardized. I myself have found Boost.TypeIndex library to be
> most helpful for use-cases that I listed. However lot of people are
> afraid of Boost ... so it is hard to suggest.
 
He.
 
Thanks,
Lynn
Ian Collins <ian-news@hotmail.com>: Nov 22 05:12PM +1300

Lynn McGuire wrote:
> Class::className method in all of our classes, I was just wondering if
> we could forgo that now. I forget why, but virtualization does not work
> in this particular case other than to supply the name of the class.
 
How many classes do you have? I some code that uses the index in a
typelist to generate a unique numerical ID for each type.
 
--
Ian Collins
Jorgen Grahn <grahn+nntp@snipabacken.se>: Nov 22 10:52AM

On Sat, 2015-11-21, 嘱 Tiib wrote:
...
> I myself have found Boost.TypeIndex library to be
> most helpful for use-cases that I listed. However lot of people are
> afraid of Boost ... so it is hard to suggest.
 
This is a bit embarrassing: I still haven't really used any part of
Boost. But surely it's a very valid suggestion? People today have
access to it, and compilers which can cope with it. Unless
Boost.TypeIndex is very bleeding edge or very complicated, it seems
like a good choice if you need to do such things.
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
Lynn McGuire <lmc@winsim.com>: Nov 22 07:43AM -0600

On 11/21/2015 10:12 PM, Ian Collins wrote:
>> in this particular case other than to supply the name of the class.
 
> How many classes do you have? I some code that uses the index in a
> typelist to generate a unique numerical ID for each type.
 
600 or so classes. I have a manually built solution for now, I was just
wondering about the future:
 
std::string RefiGroup::className ()
{
return "RefiGroup";
}
 
Thanks,
Lynn
"Öö Tiib" <ootiib@hot.ee>: Nov 22 09:46AM -0800

On Sunday, 22 November 2015 12:52:47 UTC+2, Jorgen Grahn wrote:
> > afraid of Boost ... so it is hard to suggest.
 
> This is a bit embarrassing: I still haven't really used any part of
> Boost. But surely it's a very valid suggestion?
 
For people who have to write platform-agnostic tools it is basically
best available option. For people who want to squeeze most out of sole
platform it is perhaps possible to take a day and read documentation
about hints found in <typeinfo> header for that platform.
 
Most portable C++ frameworks also contain some features but these are
usually weaker or narrower.
For example Qt 'pObj->metaObject()->className()'. It is run-time call
(OP mentioned compile-time) and it works only with objects that are
instrumented as 'Q_OBJECT'.
 
> People today have
> access to it, and compilers which can cope with it.
 
Yes, it is free, well-tested and works on most widely used platforms.
Also it is header-only and light since most of it works compile-time.
 
> Unless Boost.TypeIndex is very bleeding edge or very complicated,
> it seems like a good choice if you need to do such things.
 
TypeIndex is pure meta-programming. Meta-programming in C++ is
controversial topic. Authors of it seem to love newest features of
language but they also compensate older compilers and fix defective
compilers with the very same meta-programming. So that source
code can be quite difficult to follow even for expert at places.

It is no problem if you use it correctly, your code will look
clean and tidy. All dirty tricks are done on their side.
However on case of defect in your code you may receive scary and
incomprehensible compiler errors. :)
ram@zedat.fu-berlin.de (Stefan Ram): Nov 22 11:14AM

>>in this particular case other than to supply the name of the class.
>How many classes do you have? I some code that uses the index in a
>typelist to generate a unique numerical ID for each type.
 
When one is using QT, there also is a »meta-object compiler«
or some such that reads C++ source and generates additional
source for »meta-objects« from it. And those meta-objects
contain the name of the class for their objects AFAIK&IIRC.
ram@zedat.fu-berlin.de (Stefan Ram): Nov 22 12:00PM

>or some such that reads C++ source and generates additional
>source for »meta-objects« from it. And those meta-objects
>contain the name of the class for their objects AFAIK&IIRC.
 
There also is
 
www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3814.html
 
»Call for Compile-Time Reflection Proposals«.
 
Maybe posters can get into contact with the authors to
have their wishes added.
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: