Monday, July 27, 2009

comp.lang.c++ - 24 new messages in 16 topics - digest

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

comp.lang.c++@googlegroups.com

Today's topics:

* How can I use unqualified names? (Possibly hard or impossible?) - 5 messages,
2 authors
http://groups.google.com/group/comp.lang.c++/t/e2f24a95fe72b591?hl=en
* Hot sale Iphone 3G 16gb&8gb,Iphone3Gs,M89,M88,T32,G1,G2,TV Brand new,
unlocked,with all accessories Our policy: order 1-3pce brand mobile with a
free polo Tshirt, order more than 5 pcs brand mobiles with a free nike sneaker
(time limited) - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/99c2ff0f9b55b7d6?hl=en
* Www.toptradea.com Best mobile phones supplier Hot sale Nokia,8800arte,8600,
6300,5800,6500,E series E71,E66,E75, N seies N97,N96,N95,N86,N85,N81,N79,N78,N
72 //Our policy: order 1-3pce brand mobile with a free polo Tshirt - 1
messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/c132b26beaa71a32?hl=en
* ♬ ♫ ♪Air Jordan,Nike,Air Max,Shox,Rift,Max 2009, Jordan 2009 Wholesale and
retail, paypal payment! Welcome to www.toptradea.com - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/f153f3c7cb173768?hl=en
* Wholesale Fashion Jeans Prada,RMC,G-star,Cavalli,Iceberg,Levis,Coogi,BBC,
Laguna,True Religion Jeans www.toptradea.com - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/948b4af574275055?hl=en
* ☆*-*☆Hot sale Fashion Lady Handbags Juicy,Burberry,Gucci,LV,Prada,D&G,
Edhardy,Chanel,Coach, Jimmy-Hoo ♡www.toptradea.com♡ ☆*-*☆Hot sale Fashion Lady
Handbags Juicy,Burberry,Gucci,LV,Prada,D&G,Edhardy,Chanel,Coach, Jimmy-Hoo
♡www.top - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/d610751da099c606?hl=en
* ⊙◆⊙→Perfect Quality Nike,Jordan,max,shox,rift,Adidas,Puma,Gucci ,Edhardy,
sneakers [ www.toptradea.com] - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/7e361925825bf3ea?hl=en
* ◆♡◆Wholesale Nokia N series N97,N96,N86,N81,N85,N78,N79,N72,5800,8800,8600,
6500,6300,5800 ♪ ♪ ♪ Our policy: order 1-3pce brand mobile with a free polo
Tshirt, order more than 5 pcs brand mobiles with a free nike sneaker (time
limited)♪♪♪ - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/3cc027a097acc75f?hl=en
* Need to use "volatile" for accessing variables between threads? - 3 messages,
3 authors
http://groups.google.com/group/comp.lang.c++/t/4e68d5b929c344d4?hl=en
* dealing with lower level programmers - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/f708a2c0cfa8ce2d?hl=en
* Wow, This Is So Sad... - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/c6f3bb73a9d27bc1?hl=en
* coredump when read memory in AIX - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/a3ac003d9e578672?hl=en
* "Concepts" were removed from C++0x - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/2a650fa1f3c8016a?hl=en
* erasing from vectors with iterators, what is going on here? - 1 messages, 1
author
http://groups.google.com/group/comp.lang.c++/t/3af4bc3c089bedda?hl=en
* Wholesale Many brand t shirt Exempt freight (www.guoshitrade.com)paypal
payment - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/e3022cf6da741f0c?hl=en
* atexit - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/ecb78db904bcd136?hl=en

==============================================================================
TOPIC: How can I use unqualified names? (Possibly hard or impossible?)
http://groups.google.com/group/comp.lang.c++/t/e2f24a95fe72b591?hl=en
==============================================================================

== 1 of 5 ==
Date: Sun, Jul 26 2009 10:44 pm
From: "Alf P. Steinbach"


* Alf P. Steinbach:
> * James Kanze:
>
> [snip]
>> Extensible in what way?
>
> My up-thread usage example's definition was
>
> CPPX_DEFINE_OPTION( x, double )
> CPPX_DEFINE_OPTION( y, double )
> CPPX_DEFINE_2OPTIONCLASS( Pos2Options, cppx::options::NoBase, x, y )
>
> CPPX_DEFINE_OPTION( z, double )
> CPPX_DEFINE_1OPTIONCLASS( Pos3Options, Pos2Options, z )
>
> where the last line expresses a base-derived class relationship.
>
>
>>> In particular it can not, AFAICS, be used to produce the two
>>> option classes in my example usage code shown earlier in
>>> thread (natural modifications OK, of course), which you'll see
>>> if you try.
>>
>> I'll look at it, but I'll admit that I've never found any reason
>> to "extend" an options class. They're normally one-of sort of
>> things.
>
> So, this isn't the problem you've been dealing with. :-)

Perhaps an example can help you/others understand the intentded usage.

In MainWindow constructor (this is just ephemeral try-it-out code) there is

new Edit( *this, Edit::Params()
.text( L"Blah blah" )
.position( Point( 10, 10 ) )
.size( Point( 300, 20 ) )
);
new Button( *this, Button::Params()
.text( L"My button" )
.position( Point( 10, 40 ) )
.size( Point( 160, 24 ) )
.isDefault( true )
);

where the Params passed to the Edit control and the Params passed to the Button
control have the same .text, .position and .size elements, because they're
derived from the same base general window Params class.

The Params passed to the Button control have an additional .isDefault, which is
not meaningful for the Edit control and hence doesn't exist in Edit::Params.

In class Button the extra .isDefault option is added thusly, in a nested class
ApiWindowFactory:

class ApiWindowFactory
: public Outer::Base::ApiWindowFactory
{
typedef Outer::Base::ApiWindowFactory Base;
private:
bool myIsDefaultButton;

public:
CPPX_DEFINE_OPTION_VALUE( isDefault, bool, false )
CPPX_DEFINE_1OPTIONCLASS( Params, Base::Params, isDefault )

ApiWindowFactory(
Window& parentWindow,
Params const& params = Params()
)
: Base( parentWindow, params )
, myIsDefaultButton( params.isDefault() )
{}

virtual ButtonKind::Enum apiButtonKind() const
{
CPPX_IS_OVERRIDE_OF( Base::apiButtonKind );
return (myIsDefaultButton? ButtonKind::defPushButton :
ButtonKind::pushButton);
}
};

As you can see defining the derived Params with an extra .isDefault, adding in
derived class setters for all the base class elements (.text, .position, .size
etc.), is very very simple, two lines of code, placed right where the definition
is desired -- and no external script or extra files or ... :-)

There is a limitation of the macro implementations I posted earlier that the
base class can't be specified via typedef, but I don't consider that a problem;
rather, the problem is that I would want a simpler macro implementation.


Cheers,

- Alf


== 2 of 5 ==
Date: Mon, Jul 27 2009 1:40 am
From: James Kanze


On Jul 26, 10:35 pm, "Alf P. Steinbach" <al...@start.no> wrote:
> * James Kanze:

> > On Jul 26, 11:11 am, "Alf P. Steinbach" <al...@start.no> wrote:
> >> * James Kanze:

> >>> On Jul 25, 11:23 am, "Alf P. Steinbach" <al...@start.no> wrote:
> >>>> * James Kanze:
> >>>>> I don't know. I don't really understand what's going on,
> >>>>> without seeing the definitions of the macros you're using.

> >>>> They're ugly! :-)

> >>>> Or "in-elegant"...

> >>>> Hence the plea for simpler pure-C++ solution that supports
> >>>> the same, in particular extension and simple notation
> >>>> (client code).

> >>> Just curious, but why does it have to be "pure-C++"? As I
> >>> said earlier, a short AWK script does the job just fine.

> >> Why not pure C++?

> > Because some other tool does the job better? "Pure C++" isn't a
> > particular goal in my mind, any more than "pure OO" or pure
> > anything else. I use the tools best fitted for the job.

> Avoiding extra languages is a worthwhile goal.

Why?

> With extra languages other people need to be familiar with
> them;

True. In the end, it's a trade-off. But anyone who knows C++
can learn AWK in an hour or so, and it's a generally useful
tool. And of course, you'll end up using extra languages
anyway; you're not going to write all of the C++ by hand.

Also, of course, with the correct tool kit, the AWK can be
transcribed into C++ with little extra work. (See things like
FieldArray, at my site. That's really all you'd need in this
case, but I also have a class for creating C++ sources, which
manages namespaces and include files, and automatically
generates the header (with copyright), footer (with
configuration information for emacs and vim), and if the
filename ends with .*hh, .hpp, .hxx, .h or .H, the include
guards. (Which means that the results would be more complete
than with my AWK script.)

Again. If it's just a one-of situation, I'd just use the
macros. If it's something that may occur again, investing a
little more time (not much) and using an external generator is
probably more effective in the long run.

> you have code generation which means that you have extra
> files that must be managed and must not be modified; the build
> process needs to accomodate the code and you have at least one
> extra build step; anyone wishing to use your code needs the
> tools for the extra language, which may not be easily
> available; so on.

But in any non-trivial project, you're going to have code
generation anyway. The only question is what tool to use. That
was behind my question as to what Windows programmers habitually
use.

> I see that as just needless complication & restriction.

> >> If something as simple as this can't be expressed easily,
> >> then at least we can (perhaps, hopefully) find out where
> >> the flaws in the language are.

> > Why is it necessarily a flaw in the language? No tool can
> > be perfect for everything. Use the most appropriate tool.

> Simple things should be simple to express.

It is simple to express. In AWK. Or in C++, if you've got the
right tools available. What you seem to want, however, is that
the program to generate the code be expressed in the same
program which it generates; that's what creates the complexity.

That always creates a complexity. If you need to do it (e.g.
because the program generating the code needs information, such
as type information, resulting from compiling other parts of the
code), then you do it. Otherwise, using an external program is
generally preferable for all but the simplest generation. It
does add a little bit of complexity to the build
procedure---when I do such things, I usually have to add two or
three lines to the makefile, manually. But keeping the
generation logic separate from the rest of the program makes
things much easier to read and understand.

> C++ isn't an inappropriate language, but that's only due to
> the factors that count against using physical code generation.

C++ isn't an inappropriate language, really. It's just a little
heavy, given the simplicity of the generation program---using
C++ for the external generation complicates the build procedure
even more.

What complicates your code is the fact that you're trying to
embed two totally independent things---the code generation, and
the program you want to compile in the end---in a single source
file. My experience with this sort of thing (e.g. TeX, or the
text macros in Intel's original ASM-86) is that it rapidly
becomes confusing.

> [snip]
> >>>> <code>
> >>>> #include <boost/mpl/clear.hpp>
> >>>> #include <boost/mpl/front.hpp>
> >>>> #include <boost/mpl/inherit.hpp>
> >>>> #include <boost/mpl/inherit_linearly.hpp>
> >>>> #include <boost/mpl/list.hpp>
> >>>> #include <boost/mpl/pop_front.hpp>

> >>>> namespace cppx { namespace typelist {

> >>>> typedef boost::mpl::clear< boost::mpl::list<> >::type Empty;

> >>> You've already lost me. I don't have the slightest
> >>> knowledge of Boost::mpl, and in general, I find most of
> >>> the advanced meta-programming idioms too complicated for
> >>> general use.

> >> I don't have the slightest knowledge either. I just used the
> >> MPL typelist, checking the docs as I wrote, instead of
> >> locating or downloading new version of Loki, or writing one
> >> from scratch (it's pretty simple, really). The above
> >> expression is probably overkill for its purpose: it addresses
> >> that the type of 'mpl::list<>', a logically empty list of
> >> types, is not the same as the type of an empty list produced
> >> by reduction of a list. Probably just

> >> typedef boost::mpl::list<>::type Empty;

> >> would suffice to define the "real" empty list type.

> >> But I don't know, I've never used that typelist
> >> implementation before, and was a bit surprised that this
> >> was necessary.

> > Well, that sounds like another reason to use something else.
> > I wouldn't use a tool that I didn't at least vaguely
> > understand.

> *Hark*.

> I find it difficult to believe that you're unfamiliar with
> typelists.

I've heard the name, but that's about it. I don't doubt that I
could learn them, if I had any reason to, but until now, I've
not had any reason to.

> But anyway, a pencil is a pencil is a pencil, there is nothing
> mysterious about them. If the pencil you grab to write
> something with is covered with very small cactus-like things
> that hurt your fingers, then, after looking around to check
> whether there's any other pencil near you, you simply wrap the
> pencil in something, and perhaps remark: "huh, that's odd, why
> the heck did they design the pencil that way". It's less work
> to wrap than to go buy a set of pencils.

But I've already got lot's of other pencils laying around:-).
For starters, AWK is installed on all of the machines I have
access to, and I know it pretty well. And if for some reason I
didn't want to use AWK, one of the first things I did when I
started using C++ was write classes to support most of what AWK
does: String (this was long before std::string existed),
RegularExpression and FieldArray (which breaks a string up into
fields). Again, the toolset is there---you could, in fact,
easily implement what I did in AWK using nothing more than
iostream and std::string (although I'd probably throw in
boost::regex for good measure).

For a number of historical reasons, my code is designed to be
built in a Unix-like environment. AWK is there, I know it, and
it is simpler to insert into the build process than C++ code
(which means you have to compile and link a separate program).
So I use it. But the important aspect, in my mind, is that the
code which generates the code is completely separate from what
it generates.

> > (It's a difficult issue, of course---I suspect that most C++
> > programmers wouldn't be capable of writing a C++ compiler, and
> > they shouldn't need that knowledge.

> In contrast it's trivial to write a typelist implementation
> that provides basic functionality, and any C++ programmer
> should be able to do so: any C++ programmer should be able to
> just sit down and write it without any second thought.

Maybe. Given that all I know about it is the name, I can't
judge. I don't really even know what it does, exactly. (I'm
guessing that it's some sort of list of types, but I don't
really know what that means, or how it is used.)

> > But I don't even know what
> > Boost::mpl---or anything in Loki---really does.)

> Boost::mpl is much more than typelists.

> But.

> A typelist is a list of types. There are two main ways to
> build a typelist: using the idea of a list as a head + a tail,
> which is a recursive definition, and using the idea of a list
> as an array, which requires defaulting on template parameters.
> The latter is what MPL does for the general 'list' type
> constructor, which is the reason that a computed MPL empty
> list has a different type.

The former sounds like Lisp:-).

> [snip]

> > For using it, there is one argument in favor of all C++, if
> > it's straightforward: presumable new people on the project
> > will understand it immediately. IMHO, as soon as you use
> > Boost::mpl, or Loki, you've lost that advantage.

> Do you need to understand the details of the innards of your
> TV to use it?

> I haven't found any need to be TV engineer (whatever) in order
> to use a TV.

> Similarly, one does not need to understand template
> metaprogramming in order to use something (such as my code)
> that uses that internally.

> If you start looking at the inner parts that you don't
> understand, and think that the high-voltage thingies etc. make
> the TV very dangerous, and that the complexity of the
> circuitry inside makes the TV unsuable, well that's wrong.

> Simply don't peer into the innards, use the controls at the
> front of the TV! :-)

But someone has to maintain the code. If it's part of an
externally provided library, then the library clients don't have
to understand it---I don't usually look at the internals of the
libraries I use. (The one exception is std::string of g++.
Because I was told it used reference counting, and was fully
thread safe. And it was suggested by other people, e.g. Herb
Sutter, that this wasn't possible. And in fact, g++'s
implementation of std::string isn't thread safe.)

> > As for maintenance: the input file for my AWK script looks
> > something like:

> > x double 3.14159
> > y int 42
> > # ...

> > It's hard for me to imagine anything easier to maintain---to add
> > a new attribute, it's one line. (In the form I actually use,
> > the AWK script is about twice as long, and the input has the
> > form:

> > [Option] # the class name...
> > x double 3.14159
> > y int 42
> > # ...

> > The results are two files, Option.hh and Option.cc.)

> With C++ you add one line and modify the line that defines the
> class, e.g., with JK as James Kanze macro prefix:

> JK_DEF_OPT( x, 3.14159 )
> JK_DEF_OPT( y, int, 42 )
> JK_DEF_OPT_CLS_2( Option, nobase, x, y )

> The result is generated code at the point of those macro
> invocations, no extra files to care about and manage, no
> generated files to remember to not modify.

You're still mentionning x and y twice:-). So you have to
insert one line, and modify another; in my version (both macros
and AWK), you just insert a single line.

Anyway: I'm supposing that the _2 in the last line specifies the
number of attributes. IMHO, that's error prone, but get rid of
that, and I think I could buy it.

Don't forget that I developped my solution with AWK before
compilers supported templates. Of any sort. And it works, so
I've had no motivation to change it. And I still suspect that
the AWK code, even with all of the options I've given it, is a
lot simpler to understand and maintain than your templates and
macros.

> E.g. the code can be generated inside any desired namespace or
> class.

My AWK script actually handles that as well:-). But that does
make it more complicated. The alternative is to include the
generated code in the context you want.

> [snip]

> > Extensible in what way?

> My up-thread usage example's definition was

> CPPX_DEFINE_OPTION( x, double )
> CPPX_DEFINE_OPTION( y, double )
> CPPX_DEFINE_2OPTIONCLASS( Pos2Options, cppx::options::NoBase, x, y )

> CPPX_DEFINE_OPTION( z, double )
> CPPX_DEFINE_1OPTIONCLASS( Pos3Options, Pos2Options, z )

> where the last line expresses a base-derived class relationship.

I could easily add that to my script, but I've never needed it.
(It's already implicitly there with the macro solution.)

> >> In particular it can not, AFAICS, be used to produce the two
> >> option classes in my example usage code shown earlier in
> >> thread (natural modifications OK, of course), which you'll see
> >> if you try.

> > I'll look at it, but I'll admit that I've never found any reason
> > to "extend" an options class. They're normally one-of sort of
> > things.

> So, this isn't the problem you've been dealing with. :-)

As I said, I've never needed it.

> >> But you make me wonder: what does the script buy you over the
> >> above, which AFAICS offers the same functionality with less
> >> code and easier maintainance?

> > First, the AWK stuff doesn't use macros, so doesn't impinge on
> > the global namespace in anyway. (My actual AWK script handles
> > options to specify the namespace in which to build the class,
> > files to include, etc.) And the AWK stuff generates a complete
> > class; there's absolutely nothing else to do. Still, for a
> > one-of use, I'd use the above; the AWK script came about because
> > it fulfilled a more or less recurrent need.

> Namespace contamination is a valid concern, but it's minimal.

Agreed. All those prefixes don't look pretty, but the get the
job done, and they don't occur in the middle of complex
expressions, or other places where they would lead to confusion.

> That the AWK stuff generates a complete class is not an
> argument in its favor. It only indicates that there something
> so AWKward ;-) about it that generating a complete class is
> somehow seen as an accomplishment. The C++ macros I presented
> of course also generate a complete class.

When I said "generates a complete class", I meant that it
generates everything you'd write if you wrote a class yourself:
a header file and a source file, with all of the includes, etc.
necessary.

> And the C++ macros that I presented don't suffer from the
> problems of the AWK script, i.e. with a proper C++ solution

> * you don't generate extra files to worry about,

If it's a separate class, don't you want it in a separate
header, with a separate source file?

(Seriously, I think it depends on the application. In my case,
the generated class was an important class in a fairly large
library, and it definitely made sense for it to behave vis-a-vis
client code like any other class in the library, with it's own
header, etc. I can imagine that in other cases, other solutions
would be preferred.)

> * you don't have extra tool requirements and extra tools
> usage, and

To which I say: so what? In practice, I already have the tool
requirements, since I require GNU make for my makefiles, and a
number of other Unix tools for things like generating and
running test suites, cleaning up flex output so it passes modern
C++ compilers, generating the documentation (using Doxygen, but
with significant pre- and post-processing), etc.

You can't develop a project with just a compiler; you need a
tool kit of some kind. (Again, that was why I asked what
Windows programmers use. You do need something.)

> * you don't restrict the generated class' namespace or container class,
> which with C++ is just where you invoke the macro.

My personal scripts allow for this as well (although they won't
generated the class as a nested class), but I'll admit that your
solution does seem simpler in this respect.

> >>> The resulting class will be bigger than necessary (since
> >>> each Fallible requires an additional bool), and slightly
> >>> slower, at least if the types involved are cheap to
> >>> construct, but I doubt that it really matters in most cases.

> >> If that's all that you require of the class then that scheme
> >> is superb, because it's simple. :-) But the little
> >> inefficiency is not necessary. Just replace Fallible with a
> >> class that constructs the contained value with the specified
> >> default.

> > But then you have to maintain the default outside of the macro
> > declarations.

> No.

> > IMHO, it's not usually a big deal, but it does mean that
> > you have to cite the name of the attribute twice, and
> > update in two locations if you add one.

> >> Of course you need one such class per option, even when the
> >> options are of the same type. And then you have the basic
> >> options-as-types scheme... ;-)
>
> > I'm not sure I follow. You need one class for each distinct
> > set of options. Typically, in a GUI, there will only be one
> > or two distinct sets of options... in a lot of GUI's, there
> > will only be one (although some components may ignore
> > certain options).

> The reason you're not sure you follow is probably that you've
> interjected comments so as to take the statement you don't
> follow out of context.

> I was taking about replacing the Fallible class you used in
> your example.

> I.e. replacing Fallible with something that for the purpose is
> simpler and more efficient (actually I've already presented
> complete code for that).

OK. You mean using a separate type for each option (and, I
suppose, putting the default value in the constructor for the
type). I'd missed that.

You still have to declare that type, before declaring the
option.

> >> But the above is not a superb solution to my little problem,
> >> for it does not let you extend the resulting class except by
> >> requiring the code that uses the setters to always use base
> >> class setters last, which to me feels very wrong.

> >> I think that problem indicates that there's a missing feature
> >> in C++, because it "should" be trivial to express, and indeed
> >> is trivial in any scripting language.

> > The basic problem is that you're "generating" code. Which is
> > fairly simple to express in interpreted languages like Lisp or
> > the shell, which can interpret the code you've just generated.
> > (In classical computer science, this is called "self modifying
> > code", and has a very bad reputation with regards to
> > maintainability.

> Uh oh, careful now. The code isn't self-modifying. The code
> isn't the kind that has a bad reputation. :-)

Well, yours isn't self modifying in the traditional sense,
because in C++, templates are completely evaluated by the
compiler, but the Lisp versions are, sort of. More importantly,
while neither is really considered the self-modifying that has
the bad reputation, IMHO, there's a real sense that at least
some meta-programming is: when you look at the source code, what
you see is not what you get. (I don't think that your code, at
least as I finally understand it, suffers from this---at least
not if you've documented the macros sufficiently.)

--
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


== 3 of 5 ==
Date: Mon, Jul 27 2009 1:47 am
From: James Kanze


On Jul 27, 7:44 am, "Alf P. Steinbach" <al...@start.no> wrote:
> * Alf P. Steinbach:
> > * James Kanze:
> > [snip]
> >> Extensible in what way?

> > My up-thread usage example's definition was

> > CPPX_DEFINE_OPTION( x, double )
> > CPPX_DEFINE_OPTION( y, double )
> > CPPX_DEFINE_2OPTIONCLASS( Pos2Options, cppx::options::NoBase, x, y )

> > CPPX_DEFINE_OPTION( z, double )
> > CPPX_DEFINE_1OPTIONCLASS( Pos3Options, Pos2Options, z )

> > where the last line expresses a base-derived class relationship.

> >>> In particular it can not, AFAICS, be used to produce the
> >>> two option classes in my example usage code shown earlier
> >>> in thread (natural modifications OK, of course), which
> >>> you'll see if you try.

> >> I'll look at it, but I'll admit that I've never found any
> >> reason to "extend" an options class. They're normally
> >> one-of sort of things.

> > So, this isn't the problem you've been dealing with. :-)

> Perhaps an example can help you/others understand the intentded usage.

> In MainWindow constructor (this is just ephemeral try-it-out code) there is

> new Edit( *this, Edit::Params()
> .text( L"Blah blah" )
> .position( Point( 10, 10 ) )
> .size( Point( 300, 20 ) )
> );
> new Button( *this, Button::Params()
> .text( L"My button" )
> .position( Point( 10, 40 ) )
> .size( Point( 160, 24 ) )
> .isDefault( true )
> );

> where the Params passed to the Edit control and the Params
> passed to the Button control have the same .text, .position
> and .size elements, because they're derived from the same base
> general window Params class.

> The Params passed to the Button control have an additional
> .isDefault, which is not meaningful for the Edit control and
> hence doesn't exist in Edit::Params.

OK. I rather suspect that this could have been used in my case
as well. In my case, most of the components shared a very large
set of options, and have few, if any, additional options (one or
two at the most), so we just used an Options class for the
common options, and additional arguments (with defaults) for the
one or two additional attributes, when present. But your
solution seems more elegant.

> In class Button the extra .isDefault option is added thusly,
> in a nested class ApiWindowFactory:

> class ApiWindowFactory
> : public Outer::Base::ApiWindowFactory
> {
> typedef Outer::Base::ApiWindowFactory Base;
> private:
> bool myIsDefaultButton;

> public:
> CPPX_DEFINE_OPTION_VALUE( isDefault, bool, false )
> CPPX_DEFINE_1OPTIONCLASS( Params, Base::Params, isDefault )

> ApiWindowFactory(
> Window& parentWindow,
> Params const& params = Params()
> )
> : Base( parentWindow, params )
> , myIsDefaultButton( params.isDefault() )
> {}

> virtual ButtonKind::Enum apiButtonKind() const
> {
> CPPX_IS_OVERRIDE_OF( Base::apiButtonKind );
> return (myIsDefaultButton? ButtonKind::defPushButton :
> ButtonKind::pushButton);
> }
> };

> As you can see defining the derived Params with an extra
> .isDefault, adding in derived class setters for all the base
> class elements (.text, .position, .size etc.), is very very
> simple, two lines of code, placed right where the definition
> is desired -- and no external script or extra files or ...
> :-)

Yep. And my solution doesn't support generating a nested class
(and making it do so would be almost impossible).

I still don't agree with your objections because an extra tool
is used---I'd rather use an extra tool than do extra work
myself. But in this case, you've pretty much convinced me that
your solution does something the "simpler" solution with the
extra tool can't, which is a strong argument in its favor.

--
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


== 4 of 5 ==
Date: Mon, Jul 27 2009 1:54 am
From: James Kanze


On Jul 26, 5:14 pm, Jerry Coffin <jerryvcof...@yahoo.com> wrote:
> In article <c0805f61-3f00-4730-92b0-
> c98e03534...@c29g2000yqd.googlegroups.com>, james.ka...@gmail.com
> says...

> [ ... ]

> > BTW: What is the Windows equivalent of AWK? There must be
> > one, or do all Windows programmers have CygWin or something
> > similar installed?

> Nah -- various versions of AWK have been compiled natively for
> Windows (and even MS-DOS) for years.

I know that. I was using a Unix-like tool kit under MS-DOS in
the late 1908's. But I'm hardly a typical Windows user; I was
wondering what typical Windows developers use.

> One project that has ported a reasonable number of the major
> GNU utilities to Windows (native, not Cygwin) is at:

> http://unxutils.sourceforge.net/

> This includes both gawk and m4, either of which would be quite
> adequate for jobs like this.

Yes. I mentioned CygWin more as a placeholder for any Unix-like
tool kit, rather than with the idea of CygWin, and only CygWin.
I'm aware of at least three others: UWin, MSys and MKS (the
latter commercial, and rather expensive---although it wasn't too
expensive in the MS-DOS days), and I don't doubt that there are
others. (I'm still looking for one which integrates well,
however. Most of them seem to go out of their way to make it
difficult to use tools other than those in the toolset. And if
I'm running Windows, and not Linux, on a machine, it's because I
want to use the Windows tools when appropriate.)

--
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


== 5 of 5 ==
Date: Mon, Jul 27 2009 2:28 am
From: "Alf P. Steinbach"


* James Kanze:
> On Jul 26, 10:35 pm, "Alf P. Steinbach" <al...@start.no> wrote:
>
>> I find it difficult to believe that you're unfamiliar with
>> typelists.
>
> I've heard the name, but that's about it. I don't doubt that I
> could learn them, if I had any reason to, but until now, I've
> not had any reason to.

[snip]
>
>> In contrast it's trivial to write a typelist implementation
>> that provides basic functionality, and any C++ programmer
>> should be able to do so: any C++ programmer should be able to
>> just sit down and write it without any second thought.
>
> Maybe. Given that all I know about it is the name, I can't
> judge. I don't really even know what it does, exactly. (I'm
> guessing that it's some sort of list of types, but I don't
> really know what that means, or how it is used.)

Typelists were popularized by Andrei. I think he invented them independently but
they already had some history. What Andrei did was to show how all the usual run
time control structures had analogs in template metaprogramming, and to build up
from that to a framework handling types just as for run time you handle values.

I made a basic example "the minimal typelist" :-), shown below.

It may interest other readers of the group (of course what this example does is
very simple, intentionally, whereas the inheritance over a list of types in the
option macro stuff I posted earlier is one or two degrees more complex):


<code>
#include <iostream>
#include <limits>

struct NoSuch {};

// General Lisp-like typelist
template< class HeadType, class TailType = NoSuch >
struct Typelist_
{
typedef HeadType Head;
typedef TailType Tail;
};

template< class T >
void showMaxValue()
{
using namespace std;
cout << numeric_limits<T>::max() << endl;
}

template< class Typelist >
void showMaxValues()
{
showMaxValue< typename Typelist::Head >();
showMaxValues< typename Typelist::Tail >();
}

template<> void showMaxValues<NoSuch>() {}

int main()
{
typedef Typelist_<int, Typelist_<float, Typelist_<double> > > Types;
showMaxValues<Types>();
}
</code>


Cheers,

- Alf

==============================================================================
TOPIC: Hot sale Iphone 3G 16gb&8gb,Iphone3Gs,M89,M88,T32,G1,G2,TV Brand new,
unlocked,with all accessories Our policy: order 1-3pce brand mobile with a
free polo Tshirt, order more than 5 pcs brand mobiles with a free nike sneaker
(time limited)
http://groups.google.com/group/comp.lang.c++/t/99c2ff0f9b55b7d6?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Jul 27 2009 12:08 am
From: peng Selina


Hot sale Iphone 3G 16gb&8gb,Iphone3Gs,M89,M88,T32,G1,G2,TV Brand
new,unlocked,with all accessories Our policy: order 1-3pce brand
mobile with a free polo Tshirt, order more than 5 pcs brand mobiles
with a free nike sneaker (time limited)
Iphone http://www.toptradea.com/category.php?id=435
Nokia http://www.toptradea.com/category.php?id=436
Blackberry http://www.toptradea.com/category.php?id=437
HTC http://www.toptradea.com/category.php?id=438
Samsung http://www.toptradea.com/category.php?id=440
Motorola http://www.toptradea.com/category.php?id=439
Toptrading Co.,ltd found in 1995, our Email&MSN is
toptradea@hotmail.com. As a manufacture supplier,we have more than 10
years experience of this business.All products are at prices from
original factory.All items have been verified by us, so they are
credible.Veries of styles can meets the different customer need, fit
customer demand to adjust the production.AAA quality,most competitive
prices is our promise. Our main products are Mobile phones,
Laptop,MP3/4/5, video games, PSP, Watches and so on, you can click our
website www.toptradea.com to have a look.

==============================================================================
TOPIC: Www.toptradea.com Best mobile phones supplier Hot sale Nokia,8800arte,
8600,6300,5800,6500,E series E71,E66,E75, N seies N97,N96,N95,N86,N85,N81,N79,
N78,N72 //Our policy: order 1-3pce brand mobile with a free polo Tshirt
http://groups.google.com/group/comp.lang.c++/t/c132b26beaa71a32?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Jul 27 2009 12:09 am
From: peng Selina


Www.toptradea.com Best mobile phones supplier Hot sale Nokia,8800arte,
8600,6300,5800,6500,E series E71,E66,E75, N seies
N97,N96,N95,N86,N85,N81,N79,N78,N72 //Our policy: order 1-3pce brand
mobile with a free polo Tshirt, order more than 5 pcs brand mobiles
with a free nike sneaker (time limited)
Iphone http://www.toptradea.com/category.php?id=435
Nokia http://www.toptradea.com/category.php?id=436
Blackberry http://www.toptradea.com/category.php?id=437
HTC http://www.toptradea.com/category.php?id=438
Samsung http://www.toptradea.com/category.php?id=440
Motorola http://www.toptradea.com/category.php?id=439
Toptrading Co.,ltd found in 1995, our Email&MSN is
toptradea@hotmail.com. As a manufacture supplier,we have more than 10
years experience of this business.All products are at prices from
original factory.All items have been verified by us, so they are
credible.Veries of styles can meets the different customer need, fit
customer demand to adjust the production.AAA quality,most competitive
prices is our promise. Our main products are Mobile phones,
Laptop,MP3/4/5, video games, PSP, Watches and so on, you can click our
website www.toptradea.com to have a look.

==============================================================================
TOPIC: ♬ ♫ ♪Air Jordan,Nike,Air Max,Shox,Rift,Max 2009, Jordan 2009 Wholesale
and retail, paypal payment! Welcome to www.toptradea.com
http://groups.google.com/group/comp.lang.c++/t/f153f3c7cb173768?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Jul 27 2009 12:11 am
From: peng Selina


Air Jordan,Nike,Air Max,Shox,Rift,Max 2009, Jordan 2009 Wholesale and
retail, paypal payment! Welcome to www.toptradea.com
Nike Air Jordan http://www.toptradea.com/category.php?id=6,
Air Jordan Fusion http://www.toptradea.com/category.php?id=7,
Nike Air Max http://www.toptradea.com/category.php?id=8,
Nike Shox http://www.toptradea.com/category.php?id=9,
Air Force 1 http://www.toptradea.com/category.php?id=14,
Nike Rift http://www.toptradea.com/category.php?id=10,
Adidas http://www.toptradea.com/category.php?id=11,
Puma http://www.toptradea.com/category.php?id=12,
Nike Blazer http://www.toptradea.com/category.php?id=20,
Ed hardy http://www.toptradea.com/category.php?id=15,
Gucci http://www.toptradea.com/category.php?id=13
Lacoste http://www.toptradea.com/category.php?id=16
Prada http://www.toptradea.com/category.php?id=17
Coogi http://www.toptradea.com/category.php?id=19
Chanel http://www.toptradea.com/category.php?id=21
Coach http://www.toptradea.com/category.php?id=22
D&G
 http://www.toptradea.com/category.php?id=23
Clarks http://www.toptradea.com/category.php?id=27
BIKKEMBERGS http://www.toptradea.com/category.php?id=26
Creative Recreation http://www.toptradea.com/category.php?id=28
Dkny http://www.toptradea.com/category.php?id=31
DSQUARED2
 http://www.toptradea.com/category.php?id=32
Hogan http://www.toptradea.com/category.php?id=33
Louboutin http://www.toptradea.com/category.php?id=34
LV shoes http://www.toptradea.com/category.php?id=35
Rich shoes http://www.toptradea.com/category.php?id=36
Supra shoes http://www.toptradea.com/category.php?id=37
Kid shoes http://www.toptradea.com/category.php?id=56
Toptrading Co.,ltd found in 1995, our Email&MSN is
toptradea@hotmail.com. As a manufacture supplier,we have more than 10
years experience of this business.All products are at prices from
original factory.All items have been verified by us, so they are
credible.Veries of styles can meets the different customer need, fit
customer demand to adjust the production.AAA quality,most competitive
prices is our promise. Our main products are Mobile phones,
Laptop,MP3/4/5, video games, PSP, Watches and so on, you can click our
website www.toptradea.com to have a look.

==============================================================================
TOPIC: Wholesale Fashion Jeans Prada,RMC,G-star,Cavalli,Iceberg,Levis,Coogi,
BBC,Laguna,True Religion Jeans www.toptradea.com
http://groups.google.com/group/comp.lang.c++/t/948b4af574275055?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Jul 27 2009 12:13 am
From: peng Selina


Wholesale Fashion Jeans Prada,RMC,G-
star,Cavalli,Iceberg,Levis,Coogi,BBC,Laguna,True Religion Jeans
www.toptradea.com
Jeans: Evisu http://www.toptradea.com/category.php?id=363 ,
Gucci http://www.toptradea.com/category.php?id=365 ,
G-star http://www.toptradea.com/category.php?id=364 ,
LV http://www.toptradea.com/category.php?id=382 ,
D&G http://www.toptradea.com/category.php?id=192 ,
Ed hardy http://www.toptradea.com/category.php?id=186 ,
Iceberg http://www.toptradea.com/category.php?id=379 ,
BBC http://www.toptradea.com/category.php?id=191 ,
RMC http://www.toptradea.com/category.php?id=369 ,
Coogi http://www.toptradea.com/category.php?id=380,
Prada http://www.toptradea.com/category.php?id=193

Toptrading Co.,ltd found in 1995, our Email&MSN is
toptradea@hotmail.com. As a manufacture supplier,we have more than 10
years experience of this business.All products are at prices from
original factory.All items have been verified by us, so they are
credible.Veries of styles can meets the different customer need, fit
customer demand to adjust the production.AAA quality,most competitive
prices is our promise. Our main products are Mobile phones,
Laptop,MP3/4/5, video games, PSP, Watches and so on, you can click our
website www.toptradea.com to have a look.

==============================================================================
TOPIC: ☆*-*☆Hot sale Fashion Lady Handbags Juicy,Burberry,Gucci,LV,Prada,D&G,
Edhardy,Chanel,Coach, Jimmy-Hoo ♡www.toptradea.com♡ ☆*-*☆Hot sale Fashion Lady
Handbags Juicy,Burberry,Gucci,LV,Prada,D&G,Edhardy,Chanel,Coach, Jimmy-Hoo
♡www.top
http://groups.google.com/group/comp.lang.c++/t/d610751da099c606?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Jul 27 2009 12:15 am
From: peng Selina


☆*-*☆Hot sale Fashion Lady Handbags
Juicy,Burberry,Gucci,LV,Prada,D&G,Edhardy,Chanel,Coach, Jimmy-Hoo
www.toptradea.com
Handbags http://www.toptradea.com/category.php?id=66
Prada Handbags http://www.toptradea.com/category.php?id=395
LV Handbags http://www.toptradea.com/category.php?id=394
Juicy Handbags http://www.toptradea.com/category.php?id=393
Jordan Handbags http://www.toptradea.com/category.php?id=392
Jimmy Hoo Handbags http://www.toptradea.com/category.php?id=391
Ed hardy Handbags http://www.toptradea.com/category.php?id=390
Fendi Handbags http://www.toptradea.com/category.php?id=389
DB Handbags http://www.toptradea.com/category.php?id=388
Coach Handbags http://www.toptradea.com/category.php?id=387
Chloe Handbags http://www.toptradea.com/category.php?id=386
Burberrys Handbags http://www.toptradea.com/category.php?id=385
Gucci Handbags http://www.toptradea.com/category.php?id=183
Chanel Handbags http://www.toptradea.com/category.php?id=185
D&G
Handbags http://www.toptradea.com/category.php?id=184
Brand-Luggages
http://www.toptradea.com/category.php?id=384

Toptrading Co.,ltd found in 1995, our Email&MSN is
toptradea@hotmail.com. As a manufacture supplier,we have more than 10
years experience of this business.All products are at prices from
original factory.All items have been verified by us, so they are
credible.Veries of styles can meets the different customer need, fit
customer demand to adjust the production.AAA quality,most competitive
prices is our promise. Our main products are Mobile phones,
Laptop,MP3/4/5, video games, PSP, Watches and so on, you can click our
website www.toptradea.com to have a look.

==============================================================================
TOPIC: ⊙◆⊙→Perfect Quality Nike,Jordan,max,shox,rift,Adidas,Puma,Gucci ,
Edhardy, sneakers [ www.toptradea.com]
http://groups.google.com/group/comp.lang.c++/t/7e361925825bf3ea?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Jul 27 2009 12:16 am
From: peng Selina


Perfect Quality Nike,Jordan,max,shox,rift,Adidas,Puma,Gucci ,Edhardy,
sneakers [ www.toptradea.com]
⊙◆⊙→Perfect Quality
Nike,Jordan,max,shox,rift,Adidas,Puma,Gucci ,Edhardy, sneakers
[ www.toptradea.com]

Nike Air Jordan http://www.toptradea.com/category.php?id=6,
Air Jordan Fusion http://www.toptradea.com/category.php?id=7,
Nike Air Max http://www.toptradea.com/category.php?id=8,
Nike Shox http://www.toptradea.com/category.php?id=9,
Air Force 1 http://www.toptradea.com/category.php?id=14,
Nike Rift http://www.toptradea.com/category.php?id=10,
Adidas http://www.toptradea.com/category.php?id=11,
Puma http://www.toptradea.com/category.php?id=12,
Nike Blazer http://www.toptradea.com/category.php?id=20,
Ed hardy http://www.toptradea.com/category.php?id=15,
Gucci http://www.toptradea.com/category.php?id=13
Lacoste http://www.toptradea.com/category.php?id=16
Prada http://www.toptradea.com/category.php?id=17
Coogi http://www.toptradea.com/category.php?id=19
Chanel http://www.toptradea.com/category.php?id=21
Coach http://www.toptradea.com/category.php?id=22
D&G
 http://www.toptradea.com/category.php?id=23
Clarks http://www.toptradea.com/category.php?id=27
BIKKEMBERGS http://www.toptradea.com/category.php?id=26
Creative Recreation http://www.toptradea.com/category.php?id=28
Dkny http://www.toptradea.com/category.php?id=31
DSQUARED2
 http://www.toptradea.com/category.php?id=32
Hogan http://www.toptradea.com/category.php?id=33
Louboutin http://www.toptradea.com/category.php?id=34
LV shoes http://www.toptradea.com/category.php?id=35
Rich shoes http://www.toptradea.com/category.php?id=36
Supra shoes http://www.toptradea.com/category.php?id=37
Kid shoes http://www.toptradea.com/category.php?id=56

Toptrading Co.,ltd found in 1995, our Email&MSN is
toptradea@hotmail.com. As a manufacture supplier,we have more than 10
years experience of this business.All products are at prices from
original factory.All items have been verified by us, so they are
credible.Veries of styles can meets the different customer need, fit
customer demand to adjust the production.AAA quality,most competitive
prices is our promise. Our main products are Mobile phones,
Laptop,MP3/4/5, video games, PSP, Watches and so on, you can click our
website www.toptradea.com to have a look.

==============================================================================
TOPIC: ◆♡◆Wholesale Nokia N series N97,N96,N86,N81,N85,N78,N79,N72,5800,8800,
8600,6500,6300,5800 ♪ ♪ ♪ Our policy: order 1-3pce brand mobile with a free
polo Tshirt, order more than 5 pcs brand mobiles with a free nike sneaker (
time limited)♪♪♪
http://groups.google.com/group/comp.lang.c++/t/3cc027a097acc75f?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Jul 27 2009 12:18 am
From: peng Selina


◆♡◆Wholesale Nokia N series
N97,N96,N86,N81,N85,N78,N79,N72,5800,8800,8600,6500,6300,5800 ♪ ♪ ♪
Our policy: order 1-3pce brand mobile with a free polo Tshirt, order
more than 5 pcs brand mobiles with a free nike sneaker (time limited)
♪♪♪

Iphone http://www.toptradea.com/category.php?id=435
Nokia http://www.toptradea.com/category.php?id=436
Blackberry http://www.toptradea.com/category.php?id=437
HTC http://www.toptradea.com/category.php?id=438
Samsung http://www.toptradea.com/category.php?id=440
Motorola http://www.toptradea.com/category.php?id=439

Toptrading Co.,ltd found in 1995, our Email&MSN is
toptradea@hotmail.com. As a manufacture supplier,we have more than 10
years experience of this business.All products are at prices from
original factory.All items have been verified by us, so they are
credible.Veries of styles can meets the different customer need, fit
customer demand to adjust the production.AAA quality,most competitive
prices is our promise. Our main products are Mobile phones,
Laptop,MP3/4/5, video games, PSP, Watches and so on, you can click our
website www.toptradea.com to have a look.

==============================================================================
TOPIC: Need to use "volatile" for accessing variables between threads?
http://groups.google.com/group/comp.lang.c++/t/4e68d5b929c344d4?hl=en
==============================================================================

== 1 of 3 ==
Date: Mon, Jul 27 2009 12:40 am
From: Virchanza

Let's say I have a global variable:

int g_counter;

And let's say that this variable is accessed by two different threads.
Here's how the threads might look:

void Thread_One(void)
{
for (;;)
{
if ( !DoSomethingThatTakes15seconds() )
++g_counter;
}
}

void Thread_Two(void)
{
for (;;)
{
if ( DoSomethingThatTakes5seconds() )
--g_counter;
}
}

We need a mutex though. So the second draft would be:

void Thread_One(void)
{
for (;;)
{
if ( !DoSomething() )
{
LockMutex();

++g_counter;

UnlockMutex();
}
}
}

void Thread_Two(void)
{
for (;;)
{
if ( !DoSomething() )
{
LockMutex();

++g_counter;

UnlockMutex();
}
}
}

Finally though, I'd like to clarify one thing:

Do I need to define the g_counter as volatile? I realise that volatile
is intended to be used where the value of a variable can spontaneously
change outside of the normal flow of a program, but I don't know if
this applies to multi-threading.

I'm currently writing cross-platform software which is to be compiled
for different systems such as Windows, Linux, Solaris, Apple Mac.
These different systems have different API's for doing multi-
threading, and maybe each particular API should specify whether global
variables need to be volatile or not. (Or should it be considered
something inherent in the programming language?)

Now the thing is, I'm using the threading library that comes with
wxWidgets. (wxWidgets is a cross-platform library for creating GUI
programs in C++). Within the wxWidgets manual, I can't see anything
about the volatile keyword, so I don't know whether it's needed or
not.

To play it safe, I suppose I could just go and use the volatile
keyword and be done with it. However, this adds a very inconvenient
complication. Let's say I have a global array as follows:

int volatile figures[50];

Inside the code for one of the threads, I might add 7 to every element
of this array:

int const *const pend = figures + (sizeof figures / sizeof
*figures);

for (int *p = figures; figures != pend; ++figures)
*p += 7;

Now the problem here is that this won't compiler, reason being that I
have to tag "volatile" onto all of the pointer definitions. That's a
pain in the ass. (I did it before in a previous C program but it was
quite annoying).

What's the way to go about this? I have some people telling me there's
no need for volatile at all when it comes to multi-threading.


== 2 of 3 ==
Date: Mon, Jul 27 2009 12:51 am
From: "Alf P. Steinbach"


* Virchanza:
>
> I have some people telling me there's
> no need for volatile at all when it comes to multi-threading.

Right.


Cheers & hth.,

- Alf


== 3 of 3 ==
Date: Mon, Jul 27 2009 1:01 am
From: Marcel Müller


Hi,

Virchanza wrote:
> What's the way to go about this? I have some people telling me there's
> no need for volatile at all when it comes to multi-threading.

volatile is neither required nor sufficient for thread safety. You need
other synchronization constructs like your mutex anyway. And calling a
synchronization function includes a full membar. So all of your reads
and writes are executed before the synchronization takes place.

As far as I know e.g. gcc ignores volatile. Some compilers however turn
off optimizations which will not help at all, except that it increases
the chance of a race condition to occur.

But I have seen volatile used at places where strong thread safety is
required. So with C++ function overloading a different, more expensive
read strategy could take place in case of volatile objects.


Marcel

==============================================================================
TOPIC: dealing with lower level programmers
http://groups.google.com/group/comp.lang.c++/t/f708a2c0cfa8ce2d?hl=en
==============================================================================

== 1 of 2 ==
Date: Mon, Jul 27 2009 1:46 am
From: dsims


On Jul 9, 2:38 pm, Noah Roberts <roberts.n...@gmail.com> wrote:
> I'm rather new to the project management thing with regard to managing a
> team and I'm hoping some of the more experienced here can help me.

If you are new to managing, right now you are being tested by your
subordinates. If someone is not doing what you say ask why they
didn't. But their are many ways to ask this question. The attitude you
broadcast will be returned three times fold.
How are your communication skills? Do you listen to what your are
saying to others? Communication is key. If you walk in others shoes
you will climb mountains.
Obviously you have been managed before,
Who were your best managers and who were your worst?
Which managers made you feel appreciated?
What qualities did they possess to accomplish this feeling of
appreciation?
Do you still talk to these managers?
How is your attitude?
Are you humble and appreciative or demanding and condescending?

Is their a common activity that you can do as a group. Make a game
night or something to that effect.

== 2 of 2 ==
Date: Mon, Jul 27 2009 3:16 am
From: Richard Herring


In message
<827d8b9d-ef49-4490-831d-01116a0a9bff@g6g2000vbr.googlegroups.com>,
Brian Wood <coal@mailvault.com> writes
>On Jul 25, 3:05 pm, Brian Wood <c...@mailvault.com> wrote:
>>
>> One reason I started a company was to get away from the
>> groupthink/immaturity that is pervasive in companies today.
>> I read the hand writing on the wall in the 1990s and didn't
>> feel I had a choice.  The company was born out of necessity
>> more than than it being a goal of some sort.  Now I view it
>> as a move parallel to the pilgrims who left Europe on the
>> Mayflower and some other ships.  They didn't have it easy,
>> but they were successful in producing humbler management
>> for themselves in America.  That worked for awhile, but
>> lately we've not been getting much out of our "leaders."
>>
>
>
>Here's a few headlines from July 25, 2009
>http://wnd.com
>
>Analyst says Obama will change healthcare plan
>'The president hates one thing more than anything else – losing'
>
>GOP not allowed to say 'government-run health care'
>Communications with constituents that use phrase lose franking
>privilege
>

Did you have a question about C++?

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.12

--
Richard Herring

==============================================================================
TOPIC: Wow, This Is So Sad...
http://groups.google.com/group/comp.lang.c++/t/c6f3bb73a9d27bc1?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Jul 27 2009 2:01 am
From: Juha Nieminen


Default User wrote:
> Juha Nieminen wrote:
>
>> Default User wrote:
>>> As has been mentioned in several previous threads, there are news
>>> providers that are doing a fine job of filtering spam at the
>>> server. I seen none of this sort of thing.
>> That's fighting the symptoms, not the cause. The problem is not
>> servers which don't filter, but servers which send the spam in the
>> first place.
>
> Irrelevant, as there's very little that can be done about it. And
> there's really only one, that's Google Groups. They care little, and
> there really isn't anyone who can make them care.

If it was some hacked server in some country which couldn't care less
about such things, then that would be true. But Google is a huge
international company with strict policies. One would think that they
can be made to do something about the problem.

==============================================================================
TOPIC: coredump when read memory in AIX
http://groups.google.com/group/comp.lang.c++/t/a3ac003d9e578672?hl=en
==============================================================================

== 1 of 2 ==
Date: Mon, Jul 27 2009 2:02 am
From: peng qiu


Hi, I met "core" in my program. Help needed to review my source code.
Detail environment:
OS: AIX 5.2.0.0 (64bit)
Complier: VisualAge C 6
-----example.c-----------
#include <stdio.h>

int main()
{
int i = 0;
char *p = "abcd";
for (i = 0; i < 10000; i++) {
printf("p[%d] = %d\n", i, p[i]);
}
}

when i reached 2750, program coredump.
I know that "write" can result in segmentation fault, what about
"read"?
Thank you very much for your help.


== 2 of 2 ==
Date: Mon, Jul 27 2009 2:25 am
From: Vladimir Jovic


peng qiu wrote:
> Hi, I met "core" in my program. Help needed to review my source code.
> Detail environment:
> OS: AIX 5.2.0.0 (64bit)
> Complier: VisualAge C 6
> -----example.c-----------
> #include <stdio.h>
>
> int main()
> {
> int i = 0;
> char *p = "abcd";
> for (i = 0; i < 10000; i++) {
> printf("p[%d] = %d\n", i, p[i]);
> }
> }
>
> when i reached 2750, program coredump.
> I know that "write" can result in segmentation fault, what about
> "read"?
> Thank you very much for your help.

Read this:
http://en.wikipedia.org/wiki/Memory_protection

==============================================================================
TOPIC: "Concepts" were removed from C++0x
http://groups.google.com/group/comp.lang.c++/t/2a650fa1f3c8016a?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Jul 27 2009 2:24 am
From: Christof Donat


Hi,

> Were "concepts" a first attempt at invention by the committee?

They were a brilliant idea. Sadly the committee was not able to stabilize
the whole thing in a way that would not completely break any remains of the
time schedule.

> Were they even trying?!!

Have you reasons to assume they did not?

> (or just trying to legitimitize the template concept,
> "throwing good money after bad"?).

Sounds like you don't like templates too much. What is wrong about them?

Christof

==============================================================================
TOPIC: erasing from vectors with iterators, what is going on here?
http://groups.google.com/group/comp.lang.c++/t/3af4bc3c089bedda?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Jul 27 2009 3:09 am
From: Richard Herring


In message
<2ed6e53b-c12d-4b80-822a-be5d657dad24@r36g2000vbn.googlegroups.com>,
awm129 <awm129@gmail.com> writes
>On Jul 24, 12:43 am, tni <nob...@example.com> wrote:
>> awm129 wrote:
>>
>> > Its like erase is removing the element AFTER the iterator I'm giving it.
>>
>> Normally, erase simply copies everything after the element(s) being
>> erased down (using the assignment operator) and then deletes the last
>> element(s).
>
>Ok, so I do need to overload operator=(). However, if what I gather
>from all the posts is correct, the destructor of the item I actually
>want to erase is NOT guaranteed to be called.

That's right. But its assignment operator _is_ called, to copy the
element ahead of it into its place, and that operator should take care
of "erasing" the old value. If it doesn't, you're going to have problems
everywhere your objects get copied, not just in vectors.

> I need this destructor
>to be called. Looks like I need to have a vector of pointers and
>explicitly delete before erase.

No, you need to ensure that the copy constructor, assignment operator
and destructor behave consistently.

You might consider implementing the assignment operator using the
copy-and-swap idiom, which will ensure that assignment effectively
invokes the destructor on the old value and the copy constructor on the
new value.

>This should also save me from all
>that copying.

And give you the responsibility of managing the lifetime of all those
pointed-to objects. Not necessarily a good tradeoff.

Worry about the cost of copying when you've determined (by profiling)
that it really exists, not before.

>Thanks all!

--
Richard Herring

==============================================================================
TOPIC: Wholesale Many brand t shirt Exempt freight (www.guoshitrade.com)paypal
payment
http://groups.google.com/group/comp.lang.c++/t/e3022cf6da741f0c?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Jul 27 2009 3:21 am
From: "www.wholesale789.com"


wholesale Lacoste polo t shirt ( www.guoshitrade.com )
wholesale Lacoste t shirt solid color ( www.guoshitrade.com )
wholesale Lacoste sweater ( www.guoshitrade.com )
wholesale Lacoste shirt ( www.guoshitrade.com )
wholesale Lacoste ( www.guoshitrade.com )
wholesale Ralph lauren ( www.guoshitrade.com )
wholesale Ralph Lauren polo ( www.guoshitrade.com )
wholesale Polo ( www.guoshitrade.com )
wholesale Ralph lauren polo t shirt( www.guoshitrade.com )
wholesale Ralph lauren t shirt ( www.guoshitrade.com )
wholesale Abercrombie & fitch shirt ( www.guoshitrade.com )
wholesale Burberry shirt ( www.guoshitrade.com )
wholesale Burberry t shirt ( www.guoshitrade.com )
wholesale NBA sports jersey ( www.guoshitrade.com )

T-Shirts
wholesale AFF T-shirt ( www.guoshitrade.com )
wholesale ARMANI T-shirt www.guoshitrade.com
wholesale BAPE T-shirt ( www.guoshitrade.com )
wholesale BBC T-shirt www.guoshitrade.com
wholesale BOSS T-shirt www.guoshitrade.com
wholesale Burberry T-shirt ( www.guoshitrade.com )
wholesale CA T-shirt men's www.guoshitrade.com
wholesale CA T-shirt women's ( www.guoshitrade.com )
wholesale COOGI T-shirt ( www.guoshitrade.com )
wholesale CRYSTAL ROCK women's ( www.guoshitrade.com )
wholesale D&G T-shirt www.guoshitrade.com
wholesale DIESEL T-shirt ( www.guoshitrade.com )
wholesale DSQUARED T-shirt men's ( www.guoshitrade.com )
wholesale DSQUARED T-shirt women's ( www.guoshitrade.com )
wholesale Eck? Unltd T-shirt ( www.guoshitrade.com )
wholesale ED T-shirt men's
wholesale ED T-shirt women's www.guoshitrade.com
wholesale EVISU T-shirt ( www.guoshitrade.com )
wholesale GGG T-shirt ( www.guoshitrade.com )
wholesale G-STAR T-shirt ( www.guoshitrade.com )
wholesale HLST T-Shirt www.guoshitrade.com
wholesale Lacoste T-shirt ( www.guoshitrade.com )
wholesale Lacoste T-shirt women's ( www.guoshitrade.com )
wholesale LRG T-shirt ( www.guoshitrade.com )
wholesale O&L T-shirt www.guoshitrade.com
wholesale POLO 3 T-shirt ( www.guoshitrade.com )
wholesale 4 T-shirt ( www.guoshitrade.com )
wholesale POLO 5 T-shirt www.guoshitrade.com
wholesale POLO T-shirt men's ( www.guoshitrade.com )
POLO T-shirt women's ( www.guoshitrade.com )
Prada T-shirt ( www.guoshitrade.com )
RUEHL T-Shirt www.guoshitrade.com
SMET T-Shirt men's ( www.guoshitrade.com )
SMET T-Shirt women's www.guoshitrade.com
VERSACE T-shirt ( www.guoshitrade.com )
A&F Abercrombie & Fitch T-shirt men's ( www.guoshitrade.com )
A&F Abercrombie & Fitch T-shirt women's ( www.guoshitrade.com )

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

== 1 of 1 ==
Date: Mon, Jul 27 2009 3:53 am
From: "Fraser Ross"


I think I know know where in 3.6.3 the description of the destruction of
local static variables is.

"If the completion of the constructor or dynamic initialization of an
object with static storage duration is sequenced before that of another,
the completion of the destructor of the second is sequenced before the
initiation of the destructor of the first."
Thats ok.

"[ Note: this definition permits concurrent destruction. -end note ]"
I'm not sure what that means.

"If an object is initialized statically, the object is destroyed in the
same order as if the object was dynamically initialized."
Is this refering to statics that are constant initialised? Couldn't it
be written better if so?


I still can't see anything that describes the order of destruction of
local statics in relation to registered atexit functions.

Fraser.


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

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: