Tuesday, March 31, 2009

comp.lang.c++ - 26 new messages in 14 topics - digest

comp.lang.c++
http://groups.google.com/group/comp.lang.c++?hl=en

comp.lang.c++@googlegroups.com

Today's topics:

* free to see the sexy picture: - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/68f771814de3c70a?hl=en
* Does anyone else wish the C++ standards committee would give us parity with
other programming languages? - 7 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/65479c8a9a474e0b?hl=en
* what are literal values and symbolic and manifest constants? - 3 messages, 3
authors
http://groups.google.com/group/comp.lang.c++/t/ef44f833eaeb1f48?hl=en
* Unignorable return value - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/3b14b8ccfba9854c?hl=en
* Thread and C++ - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/8fd26c749a69d7ad?hl=en
* Inheritance: Implementing pure virtual functions by inheriting from an
object providing an implementation - 3 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/93aaba3f11367deb?hl=en
* Standard C++ way to generate a Jump Table ??? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/7686e7082cfac191?hl=en
* why should the SGI set provide the following function - 2 messages, 2
authors
http://groups.google.com/group/comp.lang.c++/t/8cb0207b32d38e2a?hl=en
* usage of uin16_t - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/866a22d1cc8e35a4?hl=en
* a question about __STL_NULL_TMPL_ARGS - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/601311560e588009?hl=en
* Array of objects from class without default constructor - 1 messages, 1
author
http://groups.google.com/group/comp.lang.c++/t/eb868f10e0ee77dd?hl=en
* Design question: polymorphism after object creation - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/b748f0f3d941a3ba?hl=en
* changing istream default delimiter - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/e6d874483e11ae85?hl=en
* disadvantages of using STL - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/fb1f5fcc56ce965e?hl=en

==============================================================================
TOPIC: free to see the sexy picture:
http://groups.google.com/group/comp.lang.c++/t/68f771814de3c70a?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Mar 30 2009 11:42 pm
From: hari 1


GRAB THE GOLDEN OPPURTUNITY:


earn more money in the home:


free register more income:


and also post your adv free on your computer:


click here below:


************************************
http://www.impactglobalisation.webs.com

************************************

==============================================================================
TOPIC: Does anyone else wish the C++ standards committee would give us parity
with other programming languages?
http://groups.google.com/group/comp.lang.c++/t/65479c8a9a474e0b?hl=en
==============================================================================

== 1 of 7 ==
Date: Mon, Mar 30 2009 11:35 pm
From: "Tony"

"James Kanze" <james.kanze@gmail.com> wrote in message
news:a9b595e9-3d4e-4970-84c1-8437085eb4f7@w9g2000yqa.googlegroups.com...
On Mar 27, 6:55 pm, Anonymous Infidel <messiah2...@yahoo.com> wrote:
> > >Or better yet, force them(C#, Java, etc) to do the catch up game....

> > Might be useful if you would clarify what in your mind is making the
> > C++ language trail behind these other languages.

> Simple...That would be all the things they can do that C++ can't.

"Which are? And what about all the things you can do in C++ that
you can't do in Java."

That's not the problem, but you seem to jump at the bit for those
opportunities to propagandize. (?).

> Note: You can use Google to see the differences between C++
> and other programming languages.

"Who needs to?"

Prima Donna" remark?

" Most of us"

Please do expound on how you assert that information. Do you have privy on
how many lurkers read this ng? Who is "us", in your mind?

Tony


== 2 of 7 ==
Date: Mon, Mar 30 2009 11:59 pm
From: "Tony"

"James Kanze" <james.kanze@gmail.com> wrote in message
news:4612b655-4d48-4fbf-ab1c-daebde7758a6@c36g2000yqn.googlegroups.com...

"I'm speaking about the people who post regularly here. I don't
know of any experienced C++ programmer who isn't competent in
several other languages as well."

Are you asserting that fluency in multiple languages is "trumping" those who
program in only one language? Why? C'mon now, C++ as the lowest level,
close-to-the hardware language and promoting potential eco-system of library
development has failed: it's for rocket scientists only and has held back
humanity (it hasn't, the implementors have). YOU may be a scientist, but to
hold back others because of technicality? Pfft!

NO BAILOUT FOR GM/CHRYSLER/FORD/C++

> > have actively programmed in several
> > different languages. Including some of the newer ones, like
> > Java or C#.

> Then why did you ask me what the differences were above?

"I didn't ask what the differences were; I know what the
differences are (and why we continue to use C++ for most serious
applications, rather than Java or C#). You claimed that there
were things you could do in Java, but not in C++. I asked you
to back up that claim. Obviously, you can't."

Sounds like a pissing contest in the making. JK pissing his false authority
first, hoping that it will delude the infidel (no pun on the troll's nick
meant).

Tony


== 3 of 7 ==
Date: Tues, Mar 31 2009 12:18 am
From: "Tony"

"Christof Donat" <cd@okunah.de> wrote in message
news:gqnknk$22l$1@svr7.m-online.net...
> Hi,
>
>> As I said, I've yet to find anything important that I could do
>> in Java that I couldn't do in C++, and I've extensive experience
>> in both languages.
>
> I'd say, e.g. writing web applications in C++ is a bit more difficult than
> just hacking a servlet.

Uh oh!! One of my first projects with my new library was going to be a web
server! (Oh, did you mean HOSTED?)

> Of course it is not impossible, but it is hard
> compared to Java

Uhh... isn't harder to say you are "slave of Sun" ("Are you a slave son?").

> . On the other hand hacking a servlet is more complicated
> than hacking a PHP script and PHP nowadays is powerfull enough to even
> crete
> bigger web applications.

That's "Administratorland".

>
> So this is just an type of application where I wouldn't prefer to use C++
> at
> the moment.

So maybe there is nothing out there for you to use or you want it for free.
Go figure. Guess you'll have to start from scratch huh.

>
>> You claimed that there
>> were things you could do in Java, but not in C++. I asked you
>> to back up that claim. Obviously, you can't.
>
> Of course it is enough to know, that C++ is turing complete.

Uh.. reality check, uh no.

> I guess his
> point was more on things that are a lot easier to do in Java than in C++.
> Other things apart from web applications that come to my mind are the more
> or less standardized OR-mapper (JDO), an aspect oriented framework for
> enterprise applications (spring), a standardized, platform independent UI
> library (Swing, I guess Qt could fill that gap), etc.

I'm not "buying" that. C++ is stillborn. It's progeny hinders it. A few
critical choices were made that will bury it. It's easy to say in
retrospect. A new language (many?) is (are?) imminent. Soon, no one will
program against C++ or Microsoft (apparently in the same category).

> Actually being
> not close to the standard library is in my oppinion the worst drawback of
> Qt.

You are young grasshopper.

Tony


== 4 of 7 ==
Date: Tues, Mar 31 2009 12:48 am
From: "Tony"

"James Kanze" <james.kanze@gmail.com> wrote in message
news:fd494040-a961-48b4-8709-5a4a95d4642f@h5g2000yqh.googlegroups.com...
On Mar 29, 2:07 pm, Christof Donat <c...@okunah.de> wrote:

> > As I said, I've yet to find anything important that I could
> > do in Java that I couldn't do in C++, and I've extensive
> > experience in both languages.

> I'd say, e.g. writing web applications in C++ is a bit more
> difficult than just hacking a servlet.

"And I'd agree. But it's not a language problem, and probably
not even a library problem."

It is.

"The existing infrastructure in web
servers is designed to support Java;"

Your paradigm: web hosts. How does that equate to "software development"?
Incoming request and can't even code up a spit back of bytes?
"Infrastructure?". Marketeering. Develop your own site (and webserver).
Problem solved. Next!

"it's not designed to
support any compiled language."

And so languages should evolved to sit on top of ... no... HTTP is a
protocol. If you're trying to map other paradigms on it, it's building on
weak foundations. Get out of the forrest to see the trees.

"If there were a demand for it,
it probably wouldn't be that hard to implement a server which
supported C++"

HTTP is a protocol and orthogonal to languages. You're proposing
horse-designed-cart.

> So this is just an type of application where I wouldn't prefer
> to use C++ at the moment.

"There are lots of applications where I choose some other
language; I've probably written more lines of AWK or Bourne
shell in the last year or two than C++. And if I were doing a
lightweight GUI client, I'd probably choose Java, simply because
Swing seems better than either wxWidgets or Qt. (Admittedly,
that might be mainly because I know it better, but the little
bit I've seen of wxWidgets hasn't impressed me, and I don't
really like Qt's policy of an additional preprocessor.) Also,
it's the type of application where Java's portability of
compiled code could be an advantage. Of course, all of this is
perfectly possible in C++: the GUI libraries are there, and
there's certainly nothing to stop a vendor from implementing C++
in a VM. (And portability isn't always an issue---more than a
few companies standardize on Windows on a PC for their client
machines.)"

You are "Programmer Extreme" in that you can program in everything. But I
wonder if you can program in anything ascribed. No offense, but I wouldn't
hire anyone on the internet in the tech groups because 1.) They know so much
about so little that they are not useful to me or 2.) They have been in a
commercial programming role and the risk of that taint (patent lawsuits etc)
is too big to take.

I will hire consultants and use them as I see appropriate though. C++
consultants: Nah, been there/here done that.

> > You claimed that there were things you could do in Java, but
> > not in C++. I asked you to back up that claim. Obviously,
> > you can't.

> Of course it is enough to know, that C++ is turing complete.

"Yes and no. I considered pointing that out, but I think that
there's a real sense that it's irrelevant. Java is also Turing
complete, but there are more than a few things that you can't
write in Java. Turing complete only concerns the actual
calculations---the fact that a language is Turing complete
doesn't necessarily mean that you'll be able to write device
drivers in it, for example. (And of course, you can't write the
kernel code which does the context switching in either Java or
C++.)"

Well why don't you write an OS?. That would look good on your resume. Get me
to use it would be even better (or worse!). ;)

> I guess his point was more on things that are a lot easier to
> do in Java than in C++.

"His point is not at all clear."

I think it was clear from the start by his nick that he intended to perturb
or be facetious, but who's to say not malevalent: more money for false
leaders? GM/Chrysler/Ford/Hitler.... Give money? Who's money? Oh you're the
President. I suggest "The Presidency" is as bankrupt as the <> HE intends to
support. Or moreso.

Tony


== 5 of 7 ==
Date: Tues, Mar 31 2009 1:09 am
From: "Tony"

"James Kanze" <james.kanze@gmail.com> wrote in message
news:fd494040-a961-48b4-8709-5a4a95d4642f@h5g2000yqh.googlegroups.com...

"There are certainly cases where other languages are to be
preferred"

That set reduces from a top-down analysis rather than a bottom-up on (not
that most programmers stagnate in the realm of code).

"; as I said, I've probably written more lines of Bourne
shell and AWk than C++ recently. But I fail to see any "lack of
parity", nor anything that the committee can or should do in
this respect."

Stop suppressing humanity and abusing people for lack of substance. If there
is substance there, show it to your audience. Else just... I don't know,
cobble a tombstone. ? We're talking about technology, not even, just
technical details... or a tactic?

" There are some important pieces missing"

Then you would have D. C++ is old, dying, has baggage insurmountable. Just
deal with it already.

": C++
doesn't have a decent module system."

As if you were young.

[snip]

10 years according to "the committee"? I not only do not recognize any
"committee" as relevant, I see it as imposing.

Tony


== 6 of 7 ==
Date: Tues, Mar 31 2009 1:16 am
From: "Tony"

"Christof Donat" <cd@okunah.de> wrote in message
news:gqq7ru$orj$1@svr7.m-online.net...
> Hi,
>
>> On Mar 29, 2:07 pm, Christof Donat <c...@okunah.de> wrote:
>>
>>> > As I said, I've yet to find anything important that I could
>>> > do in Java that I couldn't do in C++, and I've extensive
>>> > experience in both languages.
>>
>>> I'd say, e.g. writing web applications in C++ is a bit more
>>> difficult than just hacking a servlet.
>>
>> And I'd agree. But it's not a language problem, and probably
>> not even a library problem. The existing infrastructure in web
>> servers is designed to support Java;
>
> No. Most installed web servers use apache as server software.

It's administrator level dialog and not appropriate that the language level.
You want a C++ API to Apache? Surely that is there, but maybe HTTP is not
that hard and you'll want to host your own site with your own code (it
sounds so much simpler to me).

> Apache

Go to the Apache rooms. Nuff said.

Tony


== 7 of 7 ==
Date: Tues, Mar 31 2009 1:37 am
From: "Tony"

"Yannick Tremblay" <ytrembla@nyx.nyx.net> wrote in message
news:732457797.666546@irys.nyx.net...
> In article
> <12c8d09c-9a90-4dd4-9b48-c52262e4f55e@k19g2000prh.googlegroups.com>,
> Anonymous Infidel <messiah2999@yahoo.com> wrote:
>>> >Or better yet, force them(C#, Java, etc) to do the catch up game....
>>>
>>> Might be useful if you would clarify what in your mind is making the
>>> C++ language trail behind these other languages.
>>Simple...That would be all the things they can do that C++ can't.
>>
>>Note: You can use Google to see the differences between C++ and other
>>programming languages.
>
> You know, there's a difference between constructive criticism or
> starting a worthwhile discussion on possible improvements to the C++
> language and moaning or trolling.

That's quintesential lamer manager-wannabe-speak: USA meltdown, you are the
reason.

> At your post stand, I am afraid I
> can't classify them as constructive criticism...

I suggest you antagonize the White House's people rather than boring me.

>
> Of course C++ is not perfect but no language is. You can use Google
> to search anything about anything. You can use google to search for
> the difference between Java and other programming language.
>
> If you are really interested in improving on the flaws of C++, then
> please start discussing about some features that say you like in Java
> and you would like to see in C++. Who knows, there might be a simple
> way to do it, someone may have written or be motivated to write a
> library to solve this flaw or this discussion might even lead to a
> proposal to the standard committee. Your posts as they stand lead to
> nothing useful.

Didn't I already note that the "suggestion box" "theory" of first-time
"managers" (read, go to Iraq on the frontline!) IS A CLICHE!!

Tony

==============================================================================
TOPIC: what are literal values and symbolic and manifest constants?
http://groups.google.com/group/comp.lang.c++/t/ef44f833eaeb1f48?hl=en
==============================================================================

== 1 of 3 ==
Date: Tues, Mar 31 2009 12:03 am
From: "Alf P. Steinbach"


* S Claus:
> Hi all
>
> sorry about this but could anyone give me a simple explanation of what
> is a "literal" and what is a "symbolic constant" and what is a
> "manifest constant"?
>
> Is a literal practically any number or string that you store in a
> variable?
>
> And what is the difference between a "symbolic constant" and a
> "manifest constant"? Is there any difference?
>
> Thanks in advance

First, since this is crossposted to 5 groups involving different programming
languages, be very happy that be sheer coincidence you've asked about the
definitions of terms that are used about the same way in all of programming.

Otherwise we'd have had to employ some unsavory characters with ice picks, chain
saws and other equipment, and have them call on you.

Don't cross-post that massively, and ideally: post to one group only.

Now, "literal": that's a value specified directly in the source code.

"symbolic constant": that's a name that denotes a value.

"manifest constant": who knows, google it, check the author's definition. It's
evidently a constant. And evidently it's manifest in some way. :-)


Cheers, hth., and please stop that trollish cross-posting,

- Alf

--
Due to hosting requirements I need visits to <url: http://alfps.izfree.com/>.
No ads, and there is some C++ stuff! :-) Just going there is good. Linking
to it is even better! Thanks in advance!


== 2 of 3 ==
Date: Tues, Mar 31 2009 12:02 am
From: Richard Heathfield


S Claus said:

> Hi all
>
> sorry about this but could anyone give me a simple explanation of
> what is a "literal"

6, 'x', 42.0, "Hello world"

In C99, (int[]){2, 4} is also a literal.

> and what is a "symbolic constant"

EXIT_SUCCESS, EXIT_FAILURE, EOF, BUFSIZ, to name but a few. Here's
how to create them:

#define CM_PER_INCH 2.54
#define PI 4

> and what is a "manifest constant"?

6, 'x', 42.0, "Hello world"

> Is a literal practically any number or string that you store in a
> variable?

No, it's practically any number or string that you see /outside/
variables.

> And what is the difference between a "symbolic constant" and a
> "manifest constant"?

A symbolic constant is a constant that is represented in the code by
a symbol.

A manifest constant is a constant that is made manifest in the code
itself (as opposed to being represented by a symbol).

> Is there any difference?

180 degrees.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999


== 3 of 3 ==
Date: Tues, Mar 31 2009 1:04 am
From: Roedy Green


On Mon, 30 Mar 2009 22:57:01 -0700 (PDT), S Claus
<santa@temporaryinbox.com> wrote, quoted or indirectly quoted someone
who said :

>sorry about this but could anyone give me a simple explanation of what
>is a "literal" and what is a "symbolic constant" and what is a
>"manifest constant"?

See http://mindprod.com/jgloss/literal.html for literal

http://mindprod.com/jgloss/constant.html for symbolic constant.

I have never heard of a manifest constant.

There are expressions that can be evaluated at compile time. I have
not heard a short name for them. Perhaps we could call them "manifest
constants" since their value is more obvious than other constants.
--
Roedy Green Canadian Mind Products
http://mindprod.com

"Danish studies of 10,000 birds killed revealed that almost all died in
collisions with buildings, cars and wires; only 10 were killed by windmills.
Alternative energy sources are absolutely necessary.
Global warming will kill birds and bats, as well as other species,
in much greater numbers than wind power."
~ Dr. David Suzuki

==============================================================================
TOPIC: Unignorable return value
http://groups.google.com/group/comp.lang.c++/t/3b14b8ccfba9854c?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Mar 31 2009 1:22 am
From: Bart van Ingen Schenau


On Mar 30, 10:00 pm, gw7...@aol.com wrote:
>
> On 28 Mar, 20:59, Marcel Müller <news.5.ma...@spamgourmet.com> wrote:
>
> > Add
> >    bool repaint;
> > to your object and post a request to your message queue, every time the
> > repaint flag turns to true. The request handler checks and clears
> > repaint. This will merge the repaint in most cases. In an multi-threaded
> > application you may do this with atomic instructions.
> > Of course, you have to take care of the objects lifetime when doing this
> > kind of asynchronous painting. But GUI applications usually have to do
> > this anyway.
>
> One problem with this is that, if the user changes the text of a note
> (by associating it with a different file) but the note is showing an
> image instead of its text, then the note doesn't need updating if the
> image is still the same. I think all the solutions offered here have
> that problem.

As you say below, the note itself is aware of the content that is
visible. Therefor, the note can decide if this change to the content
or the state affects the visible content.
If and only if the visible content is affected, the repaint flag
should be set.

When handling the REPAINT message, you check the repaint flag. If that
flag is not set, you simply do nothing. This solves the problem of
having multiple updates that all set the repaint flag and issue a
REPAINT message (which should go hand in hand),

>
> I may be getting worked up unduly here, as the note can tell if it's
> showing an image or not, and the fact that the user may have just
> changed to showing text from an image and that this value has not been
> set yet so it thinks the fact the text has been changed doesn't affect
> it when really it does, is not a problem because if you change from an
> image to text then that in itself will require a repaint. But no-one's
> going to bother to read the whole of that sentence. :-)

Actually, I did bother to read that sentence. :-)
And I have a few comments on it.
First, the internal state of the object should always reflect the
visible state *just after the next repaint* (where the next repaint
could have been ordered by the windowing system because (part of) the
window was uncovered).
Secondly, what you say is correct, because the actions of changing the
associated text(file) and selecting to display text instead of an
image could be done in either order. The net effect of changing the
order should not differ (at most, you could have an additional,
ignored, REPAINT message).

Bart v Ingen Schenau

==============================================================================
TOPIC: Thread and C++
http://groups.google.com/group/comp.lang.c++/t/8fd26c749a69d7ad?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Mar 31 2009 1:32 am
From: Kirit Sælensminde (kayess)


On Mar 31, 3:58 am, peter koch <peter.koch.lar...@gmail.com> wrote:
> On 30 Mar., 22:16, Ioannis Vranos <ivra...@freemail.gr> wrote:
> > The stopped variable is declared volatile because it is accessed from different threads and we want to be sure
> > that it is freshly read every time it is needed. If we omitted the volatile keyword, the compiler might
> > optimize access to the variable, possibly leading to incorrect results".
>
> That is clearly wrong: if the boolean "stopped" is modified using a
> mutex only, there is no need for the volatile. What might happen is
> that stopped is not modified under the control of a mutex: if the only
> change that might take place is a change from false to true, it is my
> understanding that such a change will be safe. And even if there might
> be perverted situations where this might not be the case, I am
> confident that no implementation ever would behave like that.
> If we assume that stopped is accessed without using a mutex, it is
> possible that the value written by one thread will never propagate to
> another. The problem just is that this will not change with volatile.

I've seen a bool marked volatile cause a problem until it had a mutex
controlling access to it. It was pretty rare, maybe one time 50,000
write/reads.

I think the problem comes down to cache coherency -- the volatile may
force a memory read, but there doesn't seem to be any guarantee of
cache write throughs or cache coherency. You'd have to check the
compiler documentation for what it says, or more likely the code
produced to see what it really does.


K

==============================================================================
TOPIC: Inheritance: Implementing pure virtual functions by inheriting from an
object providing an implementation
http://groups.google.com/group/comp.lang.c++/t/93aaba3f11367deb?hl=en
==============================================================================

== 1 of 3 ==
Date: Tues, Mar 31 2009 1:39 am
From: Jaco Naude


Hi

I'm wondering if an idea that I have should work. Well the compiler
(mingw) does not seem to allow it, but I'm not sure why it does not
work.

I have an interface class:

class IManagable {
public:
virtual void setID(int new_id) = 0;
virtual int getID() = 0;
}

And an object implementing this interface:

class ManagableObject {
public:
ManagableObject () { id = -1; }
~ManagableObject ();

// Implement functions
inline void setID(int new_id) { id = new_id; }
inline int getID() { return id; }

private:
int id;
}

I've read in the FAQ that inheritance should not be used for code
reuse in general. But in my case I think it is a good idea. I want to
be able to assign unique IDs to objects implementing the interface. If
all of these objects can use the interface as well as the
ManagableObject implementation of the interface, it will reduce my
workload quite a lot I believe.

Now the problem. I have an object that I want to be able to manage
that looks like this:

class ManageMe : virtual public IManagable, public ManagableObject {
ManageMe () {}
~ManageMe () {}
}

This complains that the IManagable pure virtual public functions
aren't implemented by ManageMe. So my approach to accomplish this is
not working. Is there a different way that I can do this without
having to implement the IManagable interface in ManageMe (where the
implementation calls the ManagableObject functions).

Thanks in advance for any advice
Jaco


== 2 of 3 ==
Date: Tues, Mar 31 2009 1:57 am
From: "Alf P. Steinbach"


* Jaco Naude:
> Hi
>
> I'm wondering if an idea that I have should work. Well the compiler
> (mingw) does not seem to allow it, but I'm not sure why it does not
> work.
>
> I have an interface class:
>
> class IManagable {
> public:
> virtual void setID(int new_id) = 0;
> virtual int getID() = 0;
> }
>
> And an object implementing this interface:
>
> class ManagableObject {
> public:
> ManagableObject () { id = -1; }
> ~ManagableObject ();
>
> // Implement functions
> inline void setID(int new_id) { id = new_id; }
> inline int getID() { return id; }
>
> private:
> int id;
> }
>
> I've read in the FAQ that inheritance should not be used for code
> reuse in general. But in my case I think it is a good idea. I want to
> be able to assign unique IDs to objects implementing the interface. If
> all of these objects can use the interface as well as the
> ManagableObject implementation of the interface, it will reduce my
> workload quite a lot I believe.
>
> Now the problem. I have an object that I want to be able to manage
> that looks like this:
>
> class ManageMe : virtual public IManagable, public ManagableObject {
> ManageMe () {}
> ~ManageMe () {}
> }
>
> This complains that the IManagable pure virtual public functions
> aren't implemented by ManageMe. So my approach to accomplish this is
> not working. Is there a different way that I can do this without
> having to implement the IManagable interface in ManageMe (where the
> implementation calls the ManagableObject functions).
>
> Thanks in advance for any advice

class ManagableObject: public virtual IManagable


Cheers & hth.,

- Alf


--
Due to hosting requirements I need visits to <url: http://alfps.izfree.com/>.
No ads, and there is some C++ stuff! :-) Just going there is good. Linking
to it is even better! Thanks in advance!


== 3 of 3 ==
Date: Tues, Mar 31 2009 2:27 am
From: Jaco Naude


On Mar 31, 10:57 am, "Alf P. Steinbach" <al...@start.no> wrote:
> * Jaco Naude:
>
>
>
> > Hi
>
> > I'm wondering if an idea that I have should work. Well the compiler
> > (mingw) does not seem to allow it, but I'm not sure why it does not
> > work.
>
> > I have an interface class:
>
> > class IManagable {
> > public:
> >     virtual void setID(int new_id) = 0;
> >     virtual int getID() = 0;
> > }
>
> > And an object implementing this interface:
>
> > class ManagableObject {
> > public:
> >     ManagableObject () { id = -1; }
> >     ~ManagableObject ();
>
> >    // Implement functions
> >     inline void setID(int new_id)  { id = new_id; }
> >     inline int getID() { return id; }
>
> > private:
> >    int id;
> > }
>
> > I've read in the FAQ that inheritance should not be used for code
> > reuse in general. But in my case I think it is a good idea. I want to
> > be able to assign unique IDs to objects implementing the interface. If
> > all of these objects can use the interface as well as the
> > ManagableObject implementation of the interface, it will reduce my
> > workload quite a lot I believe.
>
> > Now the problem. I have an object that I want to be able to manage
> > that looks like this:
>
> > class ManageMe : virtual public IManagable, public ManagableObject {
> >     ManageMe () {}
> >     ~ManageMe () {}
> > }
>
> > This complains that the IManagable pure virtual public functions
> > aren't implemented by ManageMe. So my approach to accomplish this is
> > not working. Is there a different way that I can do this without
> > having to implement the IManagable interface in ManageMe (where the
> > implementation calls the ManagableObject functions).
>
> > Thanks in advance for any advice
>
> class ManagableObject: public virtual IManagable
>
> Cheers & hth.,
>
> - Alf
>
> --
> Due to hosting requirements I need visits to <url:http://alfps.izfree.com/>.
> No ads, and there is some C++ stuff! :-) Just going there is good. Linking
> to it is even better! Thanks in advance!

Hi Alf

Thanks for the suggestion, I have not thought of that.

I'll give it a go.
Thanks
Jaco

==============================================================================
TOPIC: Standard C++ way to generate a Jump Table ???
http://groups.google.com/group/comp.lang.c++/t/7686e7082cfac191?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Mar 31 2009 2:12 am
From: "Peter Olcott"

"blargg" <blargg.ei3@gishpuppy.com> wrote in message
news:blargg.ei3-3003092349270001@192.168.1.4...
> Peter Olcott wrote:
>> Paavo Helde wrote:
> [...]
>> > For helping the compiler to optize away impossible
>> > branches, I would prefer to mark them explicitly, e.g.
>> >
>> > switch(x) {
>> > case a: break;
>> > case b: break;
>> > default: std::never();
>> > }
>> >
>> > This would work the same as MSVC __assume(0), but
>> > avoiding
>> > the logical ping-pong of first assuming falsehood and
>> > then
>> > deriving something out of it.
>>
>> I have thought about your idea some more, keeping it in
>> the
>> std:: namespace would probably be a good idea, it is
>> always
>> available and never collides with any pre-existing names.
>
> Don't worry about the dust when you're still deciding
> whether to put in
> carpet or hardwood floors.
>
>> It might be better to make it into a flag instead of a
>> function: std::NEVER_OCCURS.
>
> What's a flag in this context?
>
>> This flag would be considered as a compiler hint that
>> compiler vendors would be free to ignore.
>
> The point of using a function call is that it is a
> standard semantic
> structure which occurs at a particular point in execution.
> This allows its
> invocation to mark that line of execution as never
> occurring.

Using a flag to generally mean a point in the execution
trace that is never reached may be more conventional than
specifying this with a function call. Putting this flag in
the std:: namespace prevents name collisions and this
namespace is probably as intuitive as possible. I think that
your idea is a substantial incremental improvement to my
original idea (prevents breaking exisitng code) and that my
next suggestion (possibly slightly more conventional) is a
tiny improvement to yours.

==============================================================================
TOPIC: why should the SGI set provide the following function
http://groups.google.com/group/comp.lang.c++/t/8cb0207b32d38e2a?hl=en
==============================================================================

== 1 of 2 ==
Date: Tues, Mar 31 2009 3:05 am
From: Martin Eisenberg


hpsoar wrote:

> I'm reading a book on STL, It provides many source codes of
> STL's SGI implementation. I found the following function in
> class set: iterator insert(iterator position, const value_type&
> x); As I know, the position of a value inserted to is determined
> by the red-black tree, which is used when implementing class
> set. So why should it provide this function here?

It's called insert with a hint and is among the standard's
requirements on associative containers. You use it when you know that
the hint's target value and the value(s) you're about to insert will
all be consecutive in the sequence. See table 7 in
http://std.dkuug.dk/jtc1/sc22/wg21/docs/wp/html/nov97-2/lib-containers.html#lib.associative.reqmts .


Martin

--
Quidquid latine scriptum est, altum videtur.


== 2 of 2 ==
Date: Tues, Mar 31 2009 3:33 am
From: James Kanze


On Mar 31, 7:40 am, "Alf P. Steinbach" <al...@start.no> wrote:
> * hpsoar:

> > I'm reading a book on STL, It provides many source codes of
> > STL's SGI implementation. I found the following function in
> > class set: iterator
> > insert(iterator position, const value_type& x);
> > As I know, the position of a value inserted to is determined
> > by the red-black tree, which is used when implementing class
> > set. So why should it provide this function here?

> This looks like an internal implementation detail.

> At some level of implementation an item has to be inserted at
> some specific position in the internal data structure
> (whatever that structure is), and naturally there must be some
> code for that -- used internally.

> It's not something that you should be concerned with as a user.

It's specified in the standard as part of the interface.
Basically, it guarantees amortised constant time if the new
element is inserted immediately after the element designated by
the first parameter, rather than the logrithmic time for other
inserts. I suspect that it's major use is when initializing a
set with already sorted data; using this version of insert, the
initialization is O(n), rather than O(n lg n). (And I suppose
that somewhere, there are even applications where this makes a
difference. Even if I've never seen one.)

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

==============================================================================
TOPIC: usage of uin16_t
http://groups.google.com/group/comp.lang.c++/t/866a22d1cc8e35a4?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Mar 31 2009 3:07 am
From: James Kanze


On Mar 30, 12:30 pm, "Alf P. Steinbach" <al...@start.no> wrote:
> * Pavan:

> > Hi Can you clarify following questions regarding uint16_t

> > 1> Does uint16_t is supported by Windows compilers also?

> Presumably the "also" means that you're currently using some
> non-Windows compiler where there is support for uint16_t.

> Type "wikipedia uint16_t" in the Firefox address bar served up
> a list of Google hits; the first was
> <url:http://en.wikipedia.org/wiki/Stdint.h>.

Which isn't exactly the best of what Wikipedia has to offer. To
quote:

Coding Standards for C and C++

This 1999 update to the International Organization for
Standardization's (ISO) was signed off fully in 2004.
[...]

Now, I'm not sure what the author means by "signed off
fully", but <stdint.h> is not part of the C++ standard, even
today (although it will be, and one can expect most C++
compilers to support it). (It would also be interesting to
know where the year 2004 comes from. In C, it has been
official since 1999, in Posix even earlier, and in C++,
probably 2010.) It then goes on to say that "Both C and
C++[citation needed] developers can add #include <stdint.h>
to their source code [...]", which is also highly dubious as
a general statement. (The article also quotes the Posix
standard as the primary source. I believe that the header
did originate in Posix, but the primary source today is the
C standard, and in fact, Posix isn't 100% aligned with the C
standard here---it requires int8_t, etc., indirectly making
Posix impossible to implement on a machine which doesn't
have 8 bit bytes, 2's complement, etc.)

> And that article says "The exact-width types and their
> corresponding ranges are only included in that header if
> they exist for that specific compiler/processor.".

> By the way, if a particular compiler doesn't offer [stdint.h]
> then check out the Boost equivalent.

Which has the same problem: if there is no type of the
corresponding size, the type won't be defined.

> > 2> When I use uint16_t am I always guaranteed that it cannot hold more
> > than 16 bits
> > Eg: uint16_t x = 0xffffffff; // Is it always guaranteed that the value
> > written is only 0xffff
>
> See above. That is, as we said in the old days, RTFM. :)
> Of course, you'd have to find the/a manual first, but it's
> not really that hard (see above).

Except that in this case, the "manual" (IOS/IEC 9899:1999)
isn't available on line. (Or did you mean the manual for
his compiler. That should tell him about the specific
compiler.)

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

==============================================================================
TOPIC: a question about __STL_NULL_TMPL_ARGS
http://groups.google.com/group/comp.lang.c++/t/601311560e588009?hl=en
==============================================================================

== 1 of 2 ==
Date: Tues, Mar 31 2009 3:11 am
From: hpsoar


On 3月31日, 下午1时42分, "Alf P. Steinbach" <al...@start.no> wrote:
> * hpsoar:
>
> > can anyone tell me what __STL_NULL_TMPL_ARGS is used for in STL, does
> > it just make it easier to write template functions?
>
> Identifiers containing double underscore, or starting with underscore followed
> by uppercase letter, are reserved to the implementation. They're internal
> implementation details. As a user you do not need to be concerned about them,
> except to avoid using names of that form in your own code.
>
> Cheers & hth.,
>
> - Alf
>
> --
> Due to hosting requirements I need visits to <url:http://alfps.izfree.com/>.
> No ads, and there is some C++ stuff! :-) Just going there is good. Linking
> to it is even better! Thanks in advance!

While, as I said I'm study SGI source code, I want to know how it
works in STL ...


== 2 of 2 ==
Date: Tues, Mar 31 2009 3:30 am
From: Martin Eisenberg


hpsoar wrote:

> While, as I said I'm study SGI source code, I want to know how
> it works in STL ...

You said so in another post. A newsgroup is not a web board and you
can't assume people to have seen, or read, other posts of yours.

>> > can anyone tell me what __STL_NULL_TMPL_ARGS is used for in
>> > STL, does it just make it easier to write template functions?

These things are used to make the same source work with various
compilers, especially older ones, that implement slightly deviating
syntax rules. Look at the SGI internal file stl_config.h, where
__STL_NULL_TMPL_ARGS is defined one way or another depending on a
configuration flag; and see if your book doesn't talk about
portability someplace.


Martin

--
Quidquid latine scriptum est, altum videtur.

==============================================================================
TOPIC: Array of objects from class without default constructor
http://groups.google.com/group/comp.lang.c++/t/eb868f10e0ee77dd?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Mar 31 2009 3:15 am
From: Matthias


Thank you for your answers, and suggestions!

I've finaly decided to pre-allocate storage without initialization
(a call to ::operator new, followed by static_cast) then
initialize individual elements with a placement new.

Yes, Juha, this wasn't difficult! The syntax is not easily found,
but the result is quite readable.

Thanks a lot!
--
Matthias

==============================================================================
TOPIC: Design question: polymorphism after object creation
http://groups.google.com/group/comp.lang.c++/t/b748f0f3d941a3ba?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Mar 31 2009 3:16 am
From: James Kanze


On Mar 30, 10:23 am, "Alf P. Steinbach" <al...@start.no> wrote:
> * James Kanze:

> > On Mar 29, 1:34 am, Marcel Müller <news.5.ma...@spamgourmet.com>

> >> Even an object, that is not fully complete, has some basic
> >> properties. It may be selected, it may be referenced, it has
> >> a changeable display name and so on. NULL is not sufficient.

> > In other words, your base class has some behavior. Logically,
> > this means either the template method pattern or the strategy
> > pattern---the latter means that you can defer the decision, and
> > change the implementation at will.

> As I wrote else-thread, IMHO it's not a good idea to add
> complexity just for ideological reasons.

Where are the ideological reasons here? He's described a
problem which he wants solved. I don't know enough about his
application to say whether it's appropriate for his base class
to have behavior, but there are certainly cases where it is.
The template method pattern and the strategy pattern are widely
used to solve real problems. Not just for ideological reasons.

> Objects that modify themselves to provide richer
> functionality, where that metamorphosis is (1) costly and (2)
> can fail, well it's just silly.

Objects that modify themselves in accordance to the design
specification are perfectly reasonable. Without knowing his
application, it's impossible to know whether this particular
design is appropriate, but if it is, the strategy pattern is a
standard, well established and effective solution.

> Instead keep the distinction between URI or directory entry or
> whatever, on the one hand, and what's referred to, on the
> other hand. They might implement some common interface. But I
> can't for the life of me see the point in having e.g. a
> directory entry metamorphose into a file it represents.

Again, I don't know exactly what he's doing, so I can't say.

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

==============================================================================
TOPIC: changing istream default delimiter
http://groups.google.com/group/comp.lang.c++/t/e6d874483e11ae85?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Mar 31 2009 3:29 am
From: James Kanze


On Mar 31, 5:56 am, "Amadeus W.M." <amadeu...@verizon.net> wrote:
> On Mon, 30 Mar 2009 02:39:21 -0700, James Kanze wrote:
> > It's also a hack, and abuse of the locale. As such, it can
> > only server to confuse the reader.

> Meanwhile I've turned to boost tokenizer to parse a line,
> which can handle commas within quotes too, so doing it using
> facets is only a matter of curiosity now.

In other words, you're using a tool designed for the job, rather
than a tool designed for a different job.

FWIW, if you do want to change the definition of what istream
thinks is white space, you have to:

1. Create an instance of a ctype<char> facet which defines
white space as you want. Exceptionally (because creating
new facets is normally anything but trivial), this is
simple; the standard provides a specialization of ctype for
char, which has a constructor which takes a table specifying
the types of each char, so all you have to do is write the
table and create an instance of this specialization.

Note that locale reference counts facets, so you should use
new to create the instance, and let locale itself take care
of the delete.

2. Create a locale using this facet. For this, you'd probably
use the templated constructor template< typename Facet >
std::locale::locale( std::locale const& other, Facet* ),
which creates a copy of other, with the given facet
replacing the one in the original locale.

3. Imbue your stream with this locale.

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

==============================================================================
TOPIC: disadvantages of using STL
http://groups.google.com/group/comp.lang.c++/t/fb1f5fcc56ce965e?hl=en
==============================================================================

== 1 of 1 ==
Date: Tues, Mar 31 2009 3:38 am
From: James Kanze


On Mar 30, 6:13 pm, Jeff Schwab <j...@schwabcenter.com> wrote:
> Tony wrote:
> > "Jeff Schwab" <j...@schwabcenter.com> wrote in message
> >news:0YednVRjhOfeq1DUnZ2dnUVZ_g6WnZ2d@giganews.com...
> >> Tony wrote:
> >>> "SG" <s.gesem...@gmail.com> wrote in message
> >>>news:21656158-919d-4044-ad8e-bf5db6c44788@q9g2000yqc.googlegroups.com...

> >>> "One of the main STL advantages is that it's part of the C++ standard"

> >>> I see that as a detriment, not an advantage.
> >> Why?

> > Do you know what a camel is? (And no, that's not the only reason).

> The STL was designed originally by Alex Stepanov, not by
> committee. Anyway, that's not a meaningful answer, just a
> cliche that reiterates your opinion that standardization is
> inherently detrimental. Are you saying that your dislike of
> STL is more philosophical than technical?

If I understand him correctly, he's saying that the STL is too
complicated for him to understand, that he's capable of
designing and implementing something far better, and that he's
not going to tell anyone how or what.

You figure out if that makes any sense. From his postings, I
gather that he doesn't understand beans about software
engineering. (To whit: it doesn't really matter how well
designed you find the STL---it's standard, it's what people know
and understand, and it is sufficient in most cases, so it's what
you use. Whatever it's intrinsic qualities or defaults.)

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34


==============================================================================

You received this message because you are subscribed to the Google Groups "comp.lang.c++"
group.

To post to this group, visit http://groups.google.com/group/comp.lang.c++?hl=en

To unsubscribe from this group, send email to comp.lang.c+++unsubscribe@googlegroups.com

To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c++/subscribe?hl=en

To report abuse, send email explaining the problem to abuse@googlegroups.com

==============================================================================
Google Groups: http://groups.google.com/?hl=en

No comments: