http://groups.google.com/group/comp.lang.c++?hl=en
comp.lang.c++@googlegroups.com
Today's topics:
* dealing with lower level programmers - 6 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/f708a2c0cfa8ce2d?hl=en
* "Concepts" were removed from C++0x - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/2a650fa1f3c8016a?hl=en
* passing by reference - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/44dae30d52f6c6db?hl=en
* Need to use "volatile" for accessing variables between threads? - 2 messages,
2 authors
http://groups.google.com/group/comp.lang.c++/t/4e68d5b929c344d4?hl=en
* How can I use unqualified names? (Possibly hard or impossible?) - 1 messages,
1 author
http://groups.google.com/group/comp.lang.c++/t/e2f24a95fe72b591?hl=en
* ♪♡♪Whoelsale HTC mobile phones,Google-G2,HTC-P800,HTC-P3470,HTC-S1,HTC-S600,
HTC-S900,HTC-shift-X9500,HTC-TyTN-II,HTC-X7500 Www.toptradea.com *_* 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/fb7e2b0914729e3d?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/810045f0f5492928?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/ebb7c2de588705c1?hl=en
* How to write previous element in STL list - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/2d136691c93121bf?hl=en
==============================================================================
TOPIC: dealing with lower level programmers
http://groups.google.com/group/comp.lang.c++/t/f708a2c0cfa8ce2d?hl=en
==============================================================================
== 1 of 6 ==
Date: Mon, Jul 27 2009 4:37 pm
From: Keith H Duggar
On Jul 27, 11:34 am, Andrew Tomazos <and...@tomazos.com> wrote:
> On Jul 27, 4:03 pm, James Kanze <james.ka...@gmail.com> wrote:
>
> > > I have personally seen a 400k line codebase that was written
> > > largely by one person that was (and maybe its latest versions
> > > still is) used by nearly a million people with minimal
> > > marketing.
>
> > And? A lot of people are using a lot of junk.
>
> The software in question won numerous high profile awards in the face
> of competition, and people described themselves as "huge fans" of it.
> It was noted not only for its nice user interface, but for its amazing
> robustness. It was most certainly good software. Its existence
> disproves your statement.
Why aren't you naming this "software in question"? Are you
hiding something?
KHD
== 2 of 6 ==
Date: Mon, Jul 27 2009 5:00 pm
From: Keith H Duggar
On Jul 25, 9:13 am, Pete Becker <p...@versatilecoding.com> wrote:
> Ian Collins wrote:
> > Pete Becker wrote:
> >> Ian Collins wrote:
> >>> Pete Becker wrote:
> >>>> Noah Roberts wrote:
> >>>>> Yannick Tremblay wrote:
> >>>>>> In article <GRI9m.54005$9P.45...@newsfe08.iad>,
> >>>>>> JustBoo <B...@boowho.com> wrote:
> >>>>>>> James Kanze wrote:
> >>>>>>>> What I'd really be interesting in seeing is a real life example
> >>>>>>>> of a real program written by a single person which is considered
> >>>>>>>> correct, with a statement as to what is considered correct or
> >>>>>>>> how it is known to be correct.
> >>>>>>> Bjarne Stroustrup developing a "program" (note the quotes) called
> >>>>>>> C++?
>
> >>>>>> I don't think he was alone at it although he was the main author for
> >>>>>> the original version. Then a lot of peoples tried it and suggested
> >>>>>> improvements to it... and now we are atC++0x...
>
> >>>>>C++1xyou mean :P
>
> >>>> No,C++0x.C++1xis at least five years out.
>
> >>> Do you expectC++0x to be ratified this year?
>
> >> Next year.
>
> > Ah, so x = 10!
>
> Yup. It's still the project that started in 2003. The name hasn't been
> changed.
It seems Stroustrup diasgrees with you. Below is a quote from
http://www.ddj.com/cpp/218600111
"Even after cutting "concepts," the next C++ standard may be delayed.
Sadly, there will be no C++0x (unless you count the minor corrections
in C++03). We must wait for C++1x, and hope that 'x' will be a low
digit. There is hope because C++1x is now feature complete (excepting
the possibility of some national standards bodies effectively
insisting on some feature present in the formal proposal for the
standard). "All" that is left is the massive work of resolving
outstanding technical issues and comments." - Bjarne Stroustrup
So if I read that right, he refers to standards by the
year of ratification (or expected ratification) not by
the year work starts. That also explains why everyone
was referring to it as C++0x and not C++03 (which would
be consistent with your explanation).
KHD
== 3 of 6 ==
Date: Mon, Jul 27 2009 5:40 pm
From: Pete Becker
Keith H Duggar wrote:
> On Jul 25, 9:13 am, Pete Becker <p...@versatilecoding.com> wrote:
>> Ian Collins wrote:
>>> Pete Becker wrote:
>>>> Ian Collins wrote:
>>>>> Pete Becker wrote:
>>>>>> Noah Roberts wrote:
>>>>>>> Yannick Tremblay wrote:
>>>>>>>> In article <GRI9m.54005$9P.45...@newsfe08.iad>,
>>>>>>>> JustBoo <B...@boowho.com> wrote:
>>>>>>>>> James Kanze wrote:
>>>>>>>>>> What I'd really be interesting in seeing is a real life example
>>>>>>>>>> of a real program written by a single person which is considered
>>>>>>>>>> correct, with a statement as to what is considered correct or
>>>>>>>>>> how it is known to be correct.
>>>>>>>>> Bjarne Stroustrup developing a "program" (note the quotes) called
>>>>>>>>> C++?
>>>>>>>> I don't think he was alone at it although he was the main author for
>>>>>>>> the original version. Then a lot of peoples tried it and suggested
>>>>>>>> improvements to it... and now we are atC++0x...
>>>>>>> C++1xyou mean :P
>>>>>> No,C++0x.C++1xis at least five years out.
>>>>> Do you expectC++0x to be ratified this year?
>>>> Next year.
>>> Ah, so x = 10!
>> Yup. It's still the project that started in 2003. The name hasn't been
>> changed.
>
> It seems Stroustrup diasgrees with you. Below is a quote from
>
> http://www.ddj.com/cpp/218600111
>
> "Even after cutting "concepts," the next C++ standard may be delayed.
> Sadly, there will be no C++0x (unless you count the minor corrections
> in C++03). We must wait for C++1x, and hope that 'x' will be a low
> digit. There is hope because C++1x is now feature complete (excepting
> the possibility of some national standards bodies effectively
> insisting on some feature present in the formal proposal for the
> standard). "All" that is left is the massive work of resolving
> outstanding technical issues and comments." - Bjarne Stroustrup
>
> So if I read that right, he refers to standards by the
> year of ratification (or expected ratification) not by
> the year work starts. That also explains why everyone
> was referring to it as C++0x and not C++03 (which would
> be consistent with your explanation).
>
The project is C++0x, and will continue to be.
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of
"The Standard C++ Library Extensions: a Tutorial and Reference"
(www.petebecker.com/tr1book)
== 4 of 6 ==
Date: Mon, Jul 27 2009 8:20 pm
From: Keith H Duggar
On Jul 27, 8:40 pm, Pete Becker <p...@versatilecoding.com> wrote:
> Keith H Duggar wrote:
> > On Jul 25, 9:13 am, Pete Becker <p...@versatilecoding.com> wrote:
> >> Ian Collins wrote:
> >>> Pete Becker wrote:
> >>>> Ian Collins wrote:
> >>>>> Pete Becker wrote:
> >>>>>> Noah Roberts wrote:
> >>>>>>> Yannick Tremblay wrote:
> >>>>>>>> In article <GRI9m.54005$9P.45...@newsfe08.iad>,
> >>>>>>>> JustBoo <B...@boowho.com> wrote:
> >>>>>>>>> James Kanze wrote:
> >>>>>>>>>> What I'd really be interesting in seeing is a real life example
> >>>>>>>>>> of a real program written by a single person which is considered
> >>>>>>>>>> correct, with a statement as to what is considered correct or
> >>>>>>>>>> how it is known to be correct.
> >>>>>>>>> Bjarne Stroustrup developing a "program" (note the quotes) called
> >>>>>>>>> C++?
> >>>>>>>> I don't think he was alone at it although he was the main author for
> >>>>>>>> the original version. Then a lot of peoples tried it and suggested
> >>>>>>>> improvements to it... and now we are atC++0x...
> >>>>>>> C++1xyou mean :P
> >>>>>> No,C++0x.C++1xis at least five years out.
> >>>>> Do you expectC++0x to be ratified this year?
> >>>> Next year.
> >>> Ah, so x = 10!
> >> Yup. It's still the project that started in 2003. The name hasn't been
> >> changed.
>
> > It seems Stroustrup diasgrees with you. Below is a quote from
>
> >http://www.ddj.com/cpp/218600111
>
> > "Even after cutting "concepts," the next C++ standard may be delayed.
> > Sadly, there will be no C++0x (unless you count the minor corrections
> > in C++03). We must wait for C++1x, and hope that 'x' will be a low
> > digit. There is hope because C++1x is now feature complete (excepting
> > the possibility of some national standards bodies effectively
> > insisting on some feature present in the formal proposal for the
> > standard). "All" that is left is the massive work of resolving
> > outstanding technical issues and comments." - Bjarne Stroustrup
>
> > So if I read that right, he refers to standards by the
> > year of ratification (or expected ratification) not by
> > the year work starts. That also explains why everyone
> > was referring to it as C++0x and not C++03 (which would
> > be consistent with your explanation).
>
> The project is C++0x, and will continue to be.
That's very informative, thank you. I was under the impression
it was just an unofficial name. Tell me, where on what page does
"C++0x" appear in the latest working draft?
KHD
== 5 of 6 ==
Date: Mon, Jul 27 2009 10:29 pm
From: Andrew Tomazos
On Jul 28, 1:37 am, Keith H Duggar <dug...@alum.mit.edu> wrote:
> On Jul 27, 11:34 am, Andrew Tomazos <and...@tomazos.com> wrote:
>
> > On Jul 27, 4:03 pm, James Kanze <james.ka...@gmail.com> wrote:
>
> > > > I have personally seen a 400k line codebase that was written
> > > > largely by one person that was (and maybe its latest versions
> > > > still is) used by nearly a million people with minimal
> > > > marketing.
>
> > > And? A lot of people are using a lot of junk.
>
> > The software in question won numerous high profile awards in the face
> > of competition, and people described themselves as "huge fans" of it.
> > It was noted not only for its nice user interface, but for its amazing
> > robustness. It was most certainly good software. Its existence
> > disproves your statement.
>
> Why aren't you naming this "software in question"? Are you
> hiding something?
Yes - but nothing that effects the validity of the point.
-Andrew.
== 6 of 6 ==
Date: Mon, Jul 27 2009 11:39 pm
From: Keith H Duggar
On Jul 28, 1:29 am, Andrew Tomazos <and...@tomazos.com> wrote:
> On Jul 28, 1:37 am, Keith H Duggar <dug...@alum.mit.edu> wrote:
> > On Jul 27, 11:34 am, Andrew Tomazos <and...@tomazos.com> wrote:
> > > On Jul 27, 4:03 pm, James Kanze <james.ka...@gmail.com> wrote:
>
> > > > > I have personally seen a 400k line codebase that was written
> > > > > largely by one person that was (and maybe its latest versions
> > > > > still is) used by nearly a million people with minimal
> > > > > marketing.
>
> > > > And? A lot of people are using a lot of junk.
>
> > > The software in question won numerous high profile awards in the face
> > > of competition, and people described themselves as "huge fans" of it.
> > > It was noted not only for its nice user interface, but for its amazing
> > > robustness. It was most certainly good software. Its existence
> > > disproves your statement.
>
> > Why aren't you naming this "software in question"? Are you
> > hiding something?
>
> Yes - but nothing that effects the validity of the point.
On the contrary, it affects our ability to independently evaluate
and verify your claims. Without that we can't decide the validity
of your point (since it was just a collection of anecdotal claims
as opposed to say a deduction from shared beliefs).
KHD
==============================================================================
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 4:45 pm
From: Ioannis Vranos
Rui Maciel wrote:
> Ioannis Vranos wrote:
>
>> AFAIK, the Functional programming paradigm is probably a good approach (it
>> makes it easy) for writing multithreading programs without thread-sharing.
>
> Yes, and it may even have the potential of simplifying some mundane, frequent programming tasks. Yet, that
> doesn't mean that all programming languages should support it.
>
>
>> If it is proven to be an efficient approach, I see no reason why C++
>> should remain behind and do not adopt it.
>
> That's what I don't get. Why exactly is it a good idea to bolt support for yet another programming paradigm
> onto C++? Isn't C++ complex enough as it is? In fact, when there is a need for functional programming,
> wouldn't it be better to simply use one of the many functional programming languages to perform the tasks
> where functional programming shines?
No paradigm is a perfect solution for all problems.
Check the section about "silver bullets" in the following article:
http://linux.sys-con.com/node/32929
So if a paradigm gets proven to be effective, it should be provided by a professional multiparadigm language
such as C++.
Of course, all the stuff you already know, will continue to apply.
--
Ioannis A. Vranos
C95 / C++03 Developer
==============================================================================
TOPIC: passing by reference
http://groups.google.com/group/comp.lang.c++/t/44dae30d52f6c6db?hl=en
==============================================================================
== 1 of 2 ==
Date: Mon, Jul 27 2009 5:41 pm
From: red floyd
On Jul 27, 2:11 pm, "Default User" <defaultuse...@yahoo.com> wrote:
> I saw the later post to clc. "Deleting" posts is something at best
> works partially. Many servers ignore all cancel requests, so you tend
> to end up with a situation where some people see it and some don't. Not
> to mention that it doesn't matter once others have seen it and replied.
> It's not like the OP can remove the thread.
>
OP asked me to delete my post on the grounds that it had his private
(as opposed to public posting) email. Hence I removed mine as a
favor. Good luck with that, though, John.
== 2 of 2 ==
Date: Mon, Jul 27 2009 7:31 pm
From: Jack Klein
On Mon, 27 Jul 2009 11:34:13 -0700 (PDT), red floyd
<redfloyd@gmail.com> wrote in comp.lang.c++:
> On Jul 27, 11:27 am, squid <jvstew...@gmail.com> wrote:
>
> Oh. My. Goodness. There is so much wrong here, I don't know where to
> start.
>
> I guess first, you should post in comp.lang.c, as you are coding in
> the strict C subset.
That's an extremely ignorant attitude to take, just plain wrong.
Where in the C standard is there any definition of what any code does
when compiled as C++? Even one example?
If the OP's program can be corrected to be proper C++, who are you to
take it upon yourself to redirect him to comp.lang.c?
> > I am trying to pass a pointer to a function and in the function
> > allocate some memory for it using malloc
>
> Do not use malloc in a C++ program. Use new.
>
> > and then using it in the
> > calling function. If I return the pointer in the function return
> > value and assign it to a pointer variable when I call the function it
> > works.
> > But when I try to use the pointer I sent as a parameter it
> > says the pointer variable is undefined and I am unable to access the
> > allocated memory.
>
> What book are you using that doesn't discuss the fact that C++ uses
> pass-by-value?
What sources are you using that don't mention the fact that C++
actually has true pass by reference, although C does not?
--
Jack Klein http://JK-Technology.Com
FAQs for
news:comp.lang.c http://c-faq.com/
news:comp.lang.c++ http://www.parashift.com/c++-faq-lite/
news:alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
==============================================================================
TOPIC: Need to use "volatile" for accessing variables between threads?
http://groups.google.com/group/comp.lang.c++/t/4e68d5b929c344d4?hl=en
==============================================================================
== 1 of 2 ==
Date: Mon, Jul 27 2009 7:17 pm
From: Virchanza
On Jul 28, 12:02 am, Greg Herlihy <gre...@mac.com> wrote:
> In this case, the value of the variable can change asynchronously with
> regard to the current execution flow - and it does not matter how or
> why its value may change. To the compiler a value changed by another
> thread is just as asynchronous a change as one, say, made by memory-
> mapped I/O. And in either case, the "volatile" keyword is needed to
> prevent the compiler from caching that variable's value.
And here I have another person telling me I need volatile.
Honestly I don't know who to believe. Let's say I had a function like:
void SetNullTerminatedArrayToAllFives(int *p)
{
for (;;)
{
if (!*p) return;
*p++ = 5;
}
}
And let's say I have a global null-terminated array:
int my_array[6] = {5,4,3,2,1,0};
And now let's say this will be used between threads, so I make it
volatile:
int volatile my_array[6] = {5,4,3,2,1,0};
Now the problem here is that I can't pass this array to the above
function because I'll get a type mismatch with the "volatile". Is it
necessary to do something like:
int volatile my_volatile_array[6] = {5,4,3,2,1,0};
int (&my_array)[6] = (int (&my_array)[6])my_volatile_array;
I rather create the above reference than litter my code with
"volatile". Or will creating the reference somehow subvert the
volatileness of the object???
== 2 of 2 ==
Date: Mon, Jul 27 2009 10:41 pm
From: "Chris M. Thomasson"
"James Kanze" <james.kanze@gmail.com> wrote in message
news:524fc5b3-e99e-48af-bd56-a56ca74e7366@v36g2000yqv.googlegroups.com...
On Jul 27, 2:58 pm, Virchanza <virt...@lavabit.com> wrote:
> > Volatile is intended to be used where a variable's value can
> > mysteriously change outside of the normal flow of code.
> > I'm still not sure whether "a separate thread" qualifies as
> > being mysterious enough.
> It's mysterious enough, in that sense. The point is that your
> synchronization requests have already specified that such
> changes can occur, outside the protected region. (In fact,
> many compilers, such as Sun CC, g++ and VC++, don't implement
> sufficient synchronization for volatile to be usable for much of
> anything. Such compilers are arguably broken, but you'll almost
> certainly have to use them.)
[...]
FWIW, MSVC compilers, versions 8 and above, automatically insert
load-acquire/store-release barriers for volatile loads and stores on certain
architectures (e.g., PowerPC):
_______________________________________________________________
void*
volatile_load(
void** p
) {
void* v = ATOMIC_LOAD(p);
MEMBAR #LoadStore | #LoadLoad;
return v;
}
void*
volatile_store(
void** p,
void* v
) {
MEMBAR #LoadStore | #StoreStore;
ATOMIC_STORE(p, v);
return v;
}
_______________________________________________________________
Please note that this is NOT strong enough for mutual-exclusion such that
you cannot use these memory barrier guarantees to build Petersons Algorithm.
You would need to insert a stronger membar (e.g., MEMBAR #StoreLoad |
#StoreStore) in order to prevent subsequent load from hoisting up above the
previous store in the lock acquire portion of the algorithm. However, it is
strong enough for a DCL algorithm or a producer/consumer example:
_______________________________________________________________
int data = 0;
atomic_word volatile g_flag = 0;
void single_producer() {
data = 1234;
g_flag = 1;
}
void multiple_consumers() {
while (! g_flag) backoff();
assert(data == 1234);
}
_______________________________________________________________
However, these barriers are actually too strong here such that the
#LoadStore restrain is not required for the example... On the SPARC you
could write it as:
_______________________________________________________________
int data = 0;
atomic_word g_flag = 0;
void single_producer() {
data = 1234;
MEMBAR #StoreStore;
g_flag = 1;
}
void multiple_consumers() {
while (! g_flag) backoff();
MEMBAR #LoadLoad;
assert(data == 1234);
}
_______________________________________________________________
Even then, the barriers can be too strong for architectures that support
implicit data-dependant load barriers (e.g., all but the DEC Alpha). You can
write it this way:
_______________________________________________________________
int data = 0;
int* g_flag = 0;
void single_producer() {
data = 1234;
g_flag = &data;
}
void multiple_consumers() {
while (! g_flag) backoff();
assert(*g_flag == 1234);
}
_______________________________________________________________
==============================================================================
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 1 ==
Date: Mon, Jul 27 2009 9:17 pm
From: "Alf P. Steinbach"
* Alf P. Steinbach:
> Original problem: a pack of options that may contain a great many simple
> numerical and bitset options (defined by external API), and that should
> be (1) extensible for at least two levels, like class derivation, (2)
> easy to define, (3) easily constructible specifying only those options
> of interest, defaulting on the rest, (4) clean notation for accessing
> options, with compile time checking, and (5) if possible as efficient as
> possible access of options.
I extended the solution posted else-thread so that it now supports arbitrary
levels of extension (I've only tested with two levels, though, as shown below).
That amounted to removing two lines, and inserting two lines. :-)
So, for those interested in trying it out, or commenting,
<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::list<>::type Empty;
template< class TypeList >
struct InheritLinearly_
{
typedef typename boost::mpl::inherit_linearly<
TypeList,
boost::mpl::inherit< boost::mpl::_1, boost::mpl::_2 >
>::type Type;
};
template< class TypeList >
struct Car_
{
typedef typename boost::mpl::front< TypeList >::type Type;
};
template< class TypeList >
struct Cdr_
{
typedef typename boost::mpl::pop_front< TypeList >::type Type;
};
#define CPPX_TYPELIST_ ::boost::mpl::list
} } // namespace cppx::typelist
namespace cppx { namespace options {
template< class T, class UniqueIdType >
class Value_
{
private:
T myValue;
public:
Value_(): myValue() {}
Value_( T const& v ): myValue( v ) {}
T const& value() const { return myValue; }
void setValue( T const& v ) { myValue = v; }
operator T const& () const { return value(); }
Value_& operator=( T const& v )
{
setValue( v ); return *this;
}
};
class NoBase {};
template< class SetterResult, class TopBase >
class NoBase_InheritTemplatedSetters_: public TopBase {};
template<
class OptionTypes,
class SetterResult,
class TopBase,
template< class, class, class > class OptionSetter_
>
class InheritTemplatedSetters_;
template<
class SetterResult,
class TopBase,
template< class, class, class > class OptionSetter_
>
class InheritTemplatedSetters_<
cppx::typelist::Empty, SetterResult, TopBase, OptionSetter_
>
: public TopBase
{};
template<
class OptionTypes,
class SetterResult,
class TopBase,
template< class, class, class > class OptionSetter_
>
class InheritTemplatedSetters_
: public OptionSetter_<
typename cppx::typelist::Car_<OptionTypes>::Type,
SetterResult,
InheritTemplatedSetters_<
typename cppx::typelist::Cdr_<OptionTypes>::Type,
SetterResult,
TopBase,
OptionSetter_
>
>
{};
#define CPPX_OPTION( name ) OptionValue_##name
#define CPPX_DEFINE_OPTIONSETTER( name, type ) \
template< class OptionValue, class SetterResult, class Base > \
class OptionSetter_; \
\
template< class SetterResult, class Base > \
class OptionSetter_<CPPX_OPTION( name ), SetterResult, Base> \
: public Base \
{ \
public: \
type const& name() const \
{ return CPPX_OPTION( name )::value(); } \
\
SetterResult& name( type const& value ) \
{ \
CPPX_OPTION( name )::setValue( value ); \
return static_cast<SetterResult&>( *this ); \
} \
};
#define CPPX_DEFINE_OPTION_( name, type ) \
typedef ::cppx::options::Value_< \
type, struct UniqueIdTypeFor_##name \
> CPPX_OPTION( name ); \
CPPX_DEFINE_OPTIONSETTER( name, type )
#define CPPX_DEFINE_OPTIONV( name, type, defValue ) \
class CPPX_OPTION( name ) \
: public ::cppx::options::Value_< \
type, struct UniqueIdTypeFor_##name \
> \
{ \
typedef ::cppx::options::Value_< \
type, struct UniqueIdTypeFor_##name \
> Base; \
public: \
CPPX_OPTION( name )(): Base( defValue ) {} \
CPPX_OPTION( name )( type const& v ): Base( v ) {} \
}; \
CPPX_DEFINE_OPTIONSETTER( name, type )
#define CPPX_DEFINE_VALUECLASS( name, base ) \
class name##_Values \
: public base \
, public ::cppx::typelist::InheritLinearly_< \
name##_OptionTypes \
>::Type \
{};
#define CPPX_DEFINE_TEMPLATED_SETTERS_INHERITANCE( name, base ) \
template< class SetterResult, class TopBase > \
class name##_InheritTemplatedSetters_ \
: public ::cppx::options::InheritTemplatedSetters_< \
name##_OptionTypes, \
SetterResult, \
base##_InheritTemplatedSetters_< \
SetterResult, TopBase \
>, \
OptionSetter_ \
> \
{};
#define CPPX_DEFINE_OPTIONCLASS( name, base ) \
class name \
: public name##_InheritTemplatedSetters_< \
name, \
name##_Values \
> \
{};
#define CPPX_DEFINE_VTANDO( name, base ) \
CPPX_DEFINE_VALUECLASS( name, base ) \
CPPX_DEFINE_TEMPLATED_SETTERS_INHERITANCE( name, base ) \
CPPX_DEFINE_OPTIONCLASS( name, base )
#define CPPX_DEFINE_1OPTIONCLASS( name, base, option1 ) \
typedef CPPX_TYPELIST_< \
CPPX_OPTION( option1 ) \
> name##_OptionTypes; \
CPPX_DEFINE_VTANDO( name, base )
#define CPPX_DEFINE_2OPTIONCLASS( name, base, option1, option2 ) \
typedef CPPX_TYPELIST_< \
CPPX_OPTION( option1 ), \
CPPX_OPTION( option2 ) \
> name##_OptionTypes; \
CPPX_DEFINE_VTANDO( name, base )
} } // namespace cppx::options
//------------------------ Usage:
#include <iostream>
namespace blahblah {
namespace reallyLongName {
namespace california {
struct desert
{
CPPX_DEFINE_OPTION_( x, double )
CPPX_DEFINE_OPTIONV( y, double, 12345 )
CPPX_DEFINE_2OPTIONCLASS( Pos2Options, cppx::options::NoBase, x, y )
};
}}} // namespace blahblah::reallyLongName::california
namespace blahblah {
namespace reallyLongName {
namespace texas {
struct rose
{
CPPX_DEFINE_OPTION_( z, double )
CPPX_DEFINE_1OPTIONCLASS( Pos3Options, california::desert::Pos2Options, z )
};
}}} // namespace blahblah::reallyLongName::texas
namespace blahblah {
namespace reallyLongName {
namespace washington {
struct dc
{
CPPX_DEFINE_OPTIONV( a, double, 666 )
CPPX_DEFINE_1OPTIONCLASS( Pos4Options, texas::rose::Pos3Options, a )
};
}}} // namespace blahblah::reallyLongName::washington
struct UserClass1
{
typedef ::blahblah::reallyLongName::california::desert::Pos2Options
Pos2Options;
UserClass1( Pos2Options const& options )
{
using namespace std;
cout << options.x() << endl;
cout << options.y() << endl;
}
};
struct UserClass2: UserClass1
{
typedef ::blahblah::reallyLongName::texas::rose::Pos3Options
Pos3Options;
UserClass2( Pos3Options const& options )
: UserClass1( options )
{
using namespace std;
cout << std::endl;
cout << options.x() << endl;
cout << options.y() << endl;
cout << options.z() << endl;
}
};
struct UserClass3: UserClass2
{
typedef ::blahblah::reallyLongName::washington::dc::Pos4Options
Pos4Options;
UserClass3( Pos4Options const& options )
: UserClass2( options )
{
using namespace std;
cout << std::endl;
cout << options.x() << endl;
cout << options.y() << endl;
cout << options.z() << endl;
cout << options.a() << endl;
}
};
int main()
{
using namespace std;
typedef UserClass3::Pos4Options Pos4Options;
UserClass3( Pos4Options().x( 3.14 ).z( 42 ) );
Pos4Options o;
cout << endl;
cout << typeid(o).name() << endl;
cout << "x: " << typeid(o.x(6)).name() << endl;
cout << "y: " << typeid(o.y(6)).name() << endl;
cout << "z: " << typeid(o.z(6)).name() << endl;
cout << "a: " << typeid(o.a(6)).name() << endl;
}
</code>
Cheers, & thanks to James for nudge in direction of using member routines,
- Alf
PS: Disclaimer: I haven't moved those changes back to the app I'm using this in.
So perhaps there are Issues. The only issue I know (I chose not to support that)
is that a base class can't be specified via any other name than the original.
==============================================================================
TOPIC: ♪♡♪Whoelsale HTC mobile phones,Google-G2,HTC-P800,HTC-P3470,HTC-S1,HTC-
S600,HTC-S900,HTC-shift-X9500,HTC-TyTN-II,HTC-X7500 Www.toptradea.com *_* Our
policy: order 1-3pce brand mobile with a free polo Tshirt
http://groups.google.com/group/comp.lang.c++/t/fb7e2b0914729e3d?hl=en
==============================================================================
== 1 of 1 ==
Date: Mon, Jul 27 2009 10:40 pm
From: "www.toptradea.com Toptradea"
♪♡♪Whoelsale HTC mobile phones http://www.toptradea.com/category.php?id=438,Google-G2
http://www.toptradea.com/goods.php?id=12997,HTC-P800 ,HTC-P3470
http://www.toptradea.com/goods.php?id=13019,HTC-S1,HTC-S600,HTC-S900,HTC-shift-X9500
http://www.toptradea.com/goods.php?id=13020,HTC-TyTN-II,HTC-X7500
http://www.toptradea.com/goods.php?id=12998 Www.toptradea.com *_* Our
policy: order 1-3pce brand mobile with a free polo Tshirt
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: ♡◆☆ 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/810045f0f5492928?hl=en
==============================================================================
== 1 of 1 ==
Date: Mon, Jul 27 2009 10:43 pm
From: "www.toptradea.com Toptradea"
♡◆☆ 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 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/ebb7c2de588705c1?hl=en
==============================================================================
== 1 of 1 ==
Date: Mon, Jul 27 2009 10:45 pm
From: "www.toptradea.com Toptradea"
இ◆இ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: How to write previous element in STL list
http://groups.google.com/group/comp.lang.c++/t/2d136691c93121bf?hl=en
==============================================================================
== 1 of 1 ==
Date: Mon, Jul 27 2009 11:36 pm
From: cornelis van der bent
On 27 jul, 20:16, Rolf Magnus <ramag...@t-online.de> wrote:
> cornelis van der bent wrote:
>
>
>
>
>
> > On 27 jul, 17:42, Victor Bazarov <v.Abaza...@comAcast.net> wrote:
> >> cornelis van der bent wrote:
>
> >> > In my code I want to go through all combinations of two items in a
> >> > list. Here is my code:
>
> >> > list<Instance*>::iterator i;
> >> > for (i = instances.begin(); i != --instances.end(); i++)
> >> > {
> >> > list<Instance*>::iterator j;
> >> > for (j = i + 1; j < instances.end(); j++)
> >> > {
> >> > // Do something!
> >> > }
> >> > }
>
> >> > I get a big error message at i + 1.
>
> >> Such an operation is only defined for random-access iterators, and the
> >> list iterator isn't one.
>
> > Do you know reason(s) why this has nog been implemented for a list?
> > The list is doubly-linked, so giving back an iterator one postion
> > earlier/further does not seem to be a big deal.
>
> One position not, that's why there are increment/decrement operators, but
> you cannot define addition/subtraction operators that only work with the
> value 1. They would have to be usable with any value, and adding e.g. a
> million to such an iterator (provied that the list has that many elements
> elements) would be possible, but very slow.- Tekst uit oorspronkelijk bericht niet weergeven -
>
> - Tekst uit oorspronkelijk bericht weergeven -
I agree that in language design you could leave out useless (e.g. due
to low performance) constructions. On the other hand having uniform
interfaces as much as possible has its virtues too. If it would be
possible to implement list<T>::iterator + N, I think I would choose to
do so and leave the performance issues to the user.
==============================================================================
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:
Post a Comment