Sunday, November 23, 2014

Digest for comp.lang.c++@googlegroups.com - 25 updates in 4 topics

comp.lang.c++@googlegroups.com Google Groups
Unsure why you received this message? You previously subscribed to digests from this group, but we haven't been sending them for a while. We fixed that, but if you don't want to get these messages, send an email to comp.lang.c+++unsubscribe@googlegroups.com.
Paavo Helde <myfirstname@osa.pri.ee>: Nov 23 11:02AM -0600

Chicken Mcnuggets <chicken@mcnuggets.com> wrote in
> to make some things a little lighter when a full on C++ solution might
> add extra overhead. Is it really considered that bad to have these
> things in your code?
 
Yes it is bad. And the overhead you are talking about is not there. The
most time-consuming part with arrays is dynamic allocation and
deallocation, which you have to do in C as well if the desired size of
the data is not known at compile time, and if it is known, then you can
use std::array or boost::array in C++ as well, with zero overhead. So
see, no overhead. All iterator and operator[] access is optimized away by
compilers (assuming an optimized build of course, which you have to do in
C as well anyway if performance is critical).
 
> The project I am working on is going to be open
> source, am I going to turn off C++ programmers if I have to much C
> style stuff in the code even if it is abstracted away behind classes?
 
Probably yes. If there is any kind of code review involved you will have
hard time explaining why you use cumbersome and error-prone hand-made
solutions instead of standard containers. For example, are you sure you
can make your classes properly exception-safe in the first try? And have
you properly implemented move constructors for taking advantages of C++11
performance improvements related to move semantics? If you use standard
containers, such issues are handled mostly automatically.
 
Cheers
Paavo
woodbrian77@gmail.com: Nov 23 09:27AM -0800

On Sunday, November 23, 2014 11:03:06 AM UTC-6, Paavo Helde wrote:
> you properly implemented move constructors for taking advantages of C++11
> performance improvements related to move semantics? If you use standard
> containers, such issues are handled mostly automatically.
 
I don't find much use for ::std::list, ::std::set or ::std::map.
::std::vector is OK. I use ::std::deque rarely, but wish there
were a better alternative. I use Boost containers sometimes also.
 
 
Brian
Ebenezer Enterprises - In G-d we trust.
http://webEbenezer.net
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Nov 23 05:32PM


> I don't find much use for ::std::list, ::std::set or ::std::map.
> ::std::vector is OK. I use ::std::deque rarely, but wish there
> were a better alternative. I use Boost containers sometimes also.
 
That is an idiotic thing to say Brian. All the containers are equally
useful so if you are using std::vector for everything then you are doing
it wrong.
 
/Flibble
JiiPee <no@notvalid.com>: Nov 23 05:34PM


> Brian
> Ebenezer Enterprises - In G-d we trust.
> http://webEbenezer.net
 
yes, list and sets I don't see need to use, but map is good for making
quick code if mapping needs to be done. vector is very fast so its used
a lot. But there are problems where set is also perfect.... we just have
not done those projects maybe.
JiiPee <no@notvalid.com>: Nov 23 05:38PM

On 23/11/2014 17:32, Mr Flibble wrote:
> useful so if you are using std::vector for everything then you are
> doing it wrong.
 
> /Flibble
 
The top C++ lecturers, including Bjarne, they keep saying that vector is
better than list, even in list -type of problems. Basically what they
say is that "Don't use lists, use vectors." Its propably also better in
other things, I mean more efficient. But obviously if efficiency is not
required then those slower ones can be better option as they describe
the problem better.
 
The problem with list for example is that it scatters the objects all
around the memory space and its slow to access individual items compared
to vector, if iterating (which we do most of the time normally).
Jorgen Grahn <grahn+nntp@snipabacken.se>: Nov 23 05:45PM

> On Sunday, November 23, 2014 11:03:06 AM UTC-6, Paavo Helde wrote:
>> Chicken Mcnuggets <chicken@mcnuggets.com> wrote in
>> news:aBlcw.754984$9R5.390726@fx29.am4:
...
>> containers, such issues are handled mostly automatically.
 
> I don't find much use for ::std::list, ::std::set or ::std::map.
> ::std::vector is OK.
 
I think it's fair to the OP to explain that you're unusual in your
dislike for some of the standard containers (and in how you spell
their names).
 
At least std::map/std::unordered_map sees heavy use, in the situations
where a Python programmer would use a dict, and a Perl programmer
would use a hash.
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
JiiPee <no@notvalid.com>: Nov 23 05:52PM

On 23/11/2014 17:45, Jorgen Grahn wrote:
> where a Python programmer would use a dict, and a Perl programmer
> would use a hash.
 
> /Jorgen
 
yes, I can see use for all of them except list the which I still have
not figured any use, as vector can do all what it is doing? What can the
list do the vector can not?
Chicken Mcnuggets <chicken@mcnuggets.com>: Nov 23 07:15PM


> Brian
> Ebenezer Enterprises - In G-d we trust.
> http://webEbenezer.net
 
As a Python programmer I use lists all the time. I don't know (yet)
whether C++ has the same features as Python for lists but list
comprehensions in Python allow you to do some really powerful things in
1 line of code.
 
I'm hoping you can do the same sort of thing in C++ since I use them all
the time.
 
std::map also sounds useful as it appears to essentially be a dictionary
in Python which I also use all the time.
Chicken Mcnuggets <chicken@mcnuggets.com>: Nov 23 07:18PM

On 23/11/14 08:35, Chicken Mcnuggets wrote:
 
> Anything that will increase my skill at C++ is what I am after. I have a
> project I am working on which I'd really like to get finished using C++
> and I want to make sure I'm not making any mistakes with it.
 
No one has commented on these books. I'm hovering over the buy button on
Amazon but £80 for all three is quite a bit of cash and would like to
know if they are still recommended or not.
woodbrian77@gmail.com: Nov 23 11:28AM -0800

On Sunday, November 23, 2014 11:45:15 AM UTC-6, Jorgen Grahn wrote:
> > ::std::vector is OK.
 
> I think it's fair to the OP to explain that you're unusual in your
> dislike for some of the standard containers
 
I'm not the only one. We discussed recently how
Chandler Carruth has similar views.
 
 
> At least std::map/std::unordered_map sees heavy use, in the situations
> where a Python programmer would use a dict, and a Perl programmer
> would use a hash.
 
I'd consider a Boost intrusive container or
::boost::multi_index. I'm not sure why multi_index
wasn't added to the standard years ago. Some of what
gets added isn't very good and some of what's left
out is good. Go figure.
 
 
Brian
Ebenezer Enterprises - America needs a doctor, STAT.
Ben Carson for President.
 
http://webEbenezer.net
Ian Collins <ian-news@hotmail.com>: Nov 24 08:52AM +1300


> I don't find much use for ::std::list, ::std::set or ::std::map.
> ::std::vector is OK. I use ::std::deque rarely, but wish there
> were a better alternative. I use Boost containers sometimes also.
 
What's the origin of this recent odd habit of prepending std with
superfluous colons?
 
--
Ian Collins
Richard Damon <Richard@Damon-Family.org>: Nov 23 03:23PM -0500

On 11/23/14, 2:52 PM, Ian Collins wrote:
>> were a better alternative. I use Boost containers sometimes also.
 
> What's the origin of this recent odd habit of prepending std with
> superfluous colons?
 
If guards against having a std namespace inside the namespace you code
is in. By using ::std it MUST be the globally defined and reserved for
the standard/implementation namespace.
 
I would probably reject any code at review the defined a std namespace
inside of a namespace as asking for problems, but is legal.
Jorgen Grahn <grahn+nntp@snipabacken.se>: Nov 23 08:24PM

>> dislike for some of the standard containers
 
> I'm not the only one. We discussed recently how
> Chandler Carruth has similar views.
 
Didn't mean to imply you're unique -- but I think it's fair to say
you're in a very small minority.
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
Ian Collins <ian-news@hotmail.com>: Nov 24 09:26AM +1300

Richard Damon wrote:
 
> If guards against having a std namespace inside the namespace you code
> is in. By using ::std it MUST be the globally defined and reserved for
> the standard/implementation namespace.
 
I know what it does, but I still consider it unnecessary clutter.
 
> I would probably reject any code at review the defined a std namespace
> inside of a namespace as asking for problems, but is legal.
 
Legal, but stupid!
 
--
Ian Collins
Jorgen Grahn <grahn+nntp@snipabacken.se>: Nov 23 08:34PM

On Sun, 2014-11-23, Chicken Mcnuggets wrote:
...
> whether C++ has the same features as Python for lists but list
> comprehensions in Python allow you to do some really powerful things in
> 1 line of code.
 
Then you want a combination of std::vector, the standard algorithms
and perhaps C++11 lambdas. It probably won't end up quite as concise
as a Python list comprehension, but you can still get a clear message
through to the reader.
 
> the time.
 
> std::map also sounds useful as it appears to essentially be a dictionary
> in Python which I also use all the time.
 
It's more or less the same thing, but ordered. std::unordered_map is
a bit closer to the Python concept, and generally a bit faster.
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
Chicken Mcnuggets <chicken@mcnuggets.com>: Nov 23 08:32PM

On 18/11/14 08:23, David Brown wrote:
 
>> And isn't splint still around, too?
 
> I don't think splint ever handled C++. And to my knowledge, its
> development stalled over 10 years ago.
 
Why not use the Clang static analyser? I use it for C projects all the
time and I know it supports C++.
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Nov 23 04:49PM

On 23/11/2014 16:33, Wouter van Ooijen wrote:
> specification.
 
> But again, that does not matter much for the original question. Do you
> have anything meaningfull to say on that?
 
I repeat what I said earlier: code obfuscation is totally pointless and
your assignment is also pointless and unrealistic.
 
/Flibble
Robert Wessel <robertwessel2@yahoo.com>: Nov 23 11:14AM -0600

On Sun, 23 Nov 2014 15:41:58 +0000, Mr Flibble
 
>What is the point of using such a tool? Either you are closed source in
>which you don't need it or you are open source in which case you want
>your code to be legible.
 
 
A few folks distribute software in a way that it needs to be compiled
by the user. There may be technical or business reasons for that sort
of thing. Consider a (portable) library that should run on platforms
the vendor doesn't directly support. Or code that needs to run in
interpreted form (or at least be distributed that way), for example a
lot of JavaScript*. Obfuscated** source has some appeal in those
scenarios.
 
Personally I'd sure try to avoid it, and the security possible is
limited. OTOH, a determined enough thief can extract a lot from
binary executables as well.
 
 
*Well minified JS is half way there, if you ask me.
 
**FWIW, I'm not sure when the term "shrouded source" got replaced, but
this has been around for a very long time, particularly in the Unix
world.
"Öö Tiib" <ootiib@hot.ee>: Nov 23 09:15AM -0800

On Sunday, 23 November 2014 18:05:53 UTC+2, Wouter van Ooijen wrote:
> Mr Flibble schreef op 23-Nov-14 4:41 PM:
> > On 23/11/2014 09:05, Wouter van Ooijen wrote:
> >> Anyone knows a free C++ obfuscator that can do a single .cpp file?
 
I don't know of one. C++ is compiled language without standardized
run-time reflection. Run-time reflection is not used by C++ program.
There can be implementation-specific debug information but that is
only used by external tools and so is not deployed with binaries.
Therefore the executable binary is already obfuscated and obfuscators
are for .NET and Java binaries.
 
 
> The question remains whether the use has a point or not, but FYI: I am a
> teacher and I want to give my studenst 10 versions of the implementation
> of a class, one (hopefully) correct, and 9 each with one bug.
 
If the program does anything useful then it contains defects. So there
are no hope that you can provide correct program unless all what it does
is totally abstract and useless.
 
> is to write a set of tests for the class, and find the one correct
> implementation, and for each bug the nature of the bug. Giving the plain
> source would make a text diff approach too easy.
 
If you are really teacher then you must have *huge* archive of programs
that are all broken in several ways. Even I have such archive despite I
have only sometimes reviewed pre-interview assignments of people who want
to work as C++ programmers. About half of such works do not need any
obfuscators to make them even worse. :D
 
> My students use different compilers (some of which I don't have), so it
> is not practical for me to give them the object files.
 
So you do not review their "set of tests" either? They get your code, work
on their compilers and only give you the end results? That sounds rather
distant kind of teaching.
Wouter van Ooijen <wouter@voti.nl>: Nov 23 07:07PM +0100

嘱 Tiib schreef op 23-Nov-14 6:15 PM:
 
>> My students use different compilers (some of which I don't have), so it
>> is not practical for me to give them the object files.
 
> So you do not review their "set of tests" either?
 
I don't recall saying so.
 
> They get your code, work
> on their compilers and only give you the end results? That sounds rather
> distant kind of teaching.
 
So it sounds to me too, which is why I mostly don't work that way.
 
Wouter
Geoff <geoff@invalid.invalid>: Nov 23 11:26AM -0800

On 2014-11-23 16:49:54 +0000, Mr Flibble said:
 
>> have anything meaningfull to say on that?
 
> I repeat what I said earlier: code obfuscation is totally pointless and
> your assignment is also pointless and unrealistic.
 
 
It's not pointless if you are trying to teach black-box testing.
 
If you need to create a black box but you can't compile it for diverse targets
and you need to distribute the source for the black box without disclosing the
contents then the obfuscation tool would make sense.
Jorgen Grahn <grahn+nntp@snipabacken.se>: Nov 23 08:12PM

On Sun, 2014-11-23, 嘱 Tiib wrote:
> On Sunday, 23 November 2014 18:05:53 UTC+2, Wouter van Ooijen wrote:
...
 
 
> So you do not review their "set of tests" either? They get your code, work
> on their compilers and only give you the end results? That sounds rather
> distant kind of teaching.
 
Why assume that? The students compile the obfuscated system-under-
test, write their tests, and hand them in. He reads and runs their
tests on his own system.
 
Sounds like a pretty interesting and useful exercise. They learn the
value of documented interfaces, and of programming against interfaces.
And they get to break stuff!
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
"K' Dash" <adnanrashidpk@gmail.com>: Nov 23 08:59AM -0800

can you guys give me your email address so I can share you my files. not more just 2 files.
JiiPee <no@notvalid.com>: Nov 23 05:59PM

On 23/11/2014 16:59, K' Dash wrote:
> can you guys give me your email address so I can share you my files. not more just 2 files.
 
donno all the code, but gussing: try this, does it work:
 
void GUID_LMS_application::RemoveEntry (GUID_address GUIDaddress)
{
 
for (std::vector<Entry>::iterator i=m_listentry.begin();i!=m_listentry.end ();i++)
{

if (GUIDaddress == i->GetGUIDaddress())
{
//std::cout<<"AAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n";
 
m_listentry.erase(i);
break;
}
}
}
 
what it says now (hope i did not leave errors)?
"K' Dash" <adnanrashidpk@gmail.com>: Nov 23 10:18AM -0800

not working. :(
 
my vector contains the two values
 
03-0a-0c:01:00:02:00:00:00:00:00:01 102.102.102.102
03-0a-0c:01:00:02:00:00:00:00:00:02 102.102.102.102
03-0a-0c:01:00:02:00:00:00:00:00:03 102.102.102.102
03-0a-0c:01:00:02:00:00:00:00:00:04 102.102.102.102
03-0a-0c:01:00:02:00:00:00:00:00:05 102.102.102.102==> according to code this entry need to delete.
03-0a-0c:01:00:02:00:00:00:00:00:06 102.102.102.102
03-0a-0c:01:00:02:00:00:00:00:00:07 102.102.102.102
03-0a-0c:01:00:02:00:00:00:00:00:08 102.102.102.102
03-0a-0c:01:00:02:00:00:00:00:00:09 102.102.102.102
03-0a-0c:01:00:02:00:00:00:00:00:0a 102.102.102.102
 
 
 
Entry is a class in which getter and setter functions used.
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: