Sunday, November 29, 2009

comp.lang.c++ - 25 new messages in 17 topics - digest

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

comp.lang.c++@googlegroups.com

Today's topics:

* C++ Middleware Writer version 1.10 is now on line - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/291ac5193f237b76?hl=en
* Multiple inheritance and pointer equivalence - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/6ce10e4cd7c07869?hl=en
* I don't have to tell you... - 4 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/f615b948e5cca45b?hl=en
* logging design question - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/003f14337480240c?hl=en
* Best way to search through STL maps? - 3 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/7a79fbddf985eea2?hl=en
* Boost::unordered or boost::intrusive::hashtable - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/26a53a4fb9f6fad7?hl=en
* Disabling selected boost unit tests? - 2 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/87a8fa20c5e6da69?hl=en
* Discount Wholesale brand jeans wholesale free shipping : Affliction, Armani
Jeans,Christian Audigier, Coogi, G-STAR, Levi's, True Religion Jeans(www.
dotradenow.com.cn) - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/4b91fbe90654a642?hl=en
* invalid covariant type / forward declaration? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/e8bef11116736f7d?hl=en
* ♡*★*♡Wholesale NFL Arizona Caroinals,Baffalo-Bills,Chicago-Bears,Denver-
Broncos,Detroit-Lions,Houston-Texans,NewYork-Jets,Oakland-Raiders,SanDiego-
Chargers,etc - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/82c05842a979afde?hl=en
* HashTable - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/5a6dd10761e736f9?hl=en
* ▧▤▨HOT SALE Brand Sunglasses Gucci,Chanel,DG,Armani,LV,Coach,Edhardy,
Burberry,Prada,Ferri etc Sunglasses WWW.toptradea.com - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/3970fe876e3728bd?hl=en
* ★→★→★→Sneaker Nike,Jordan,Gucci,Adidas,Puma,EdhardyShox,Max,Free,Rift
sneaker and Levis,Polo,Lacoste,BBC,Gucci,Armani,LV,Christina Audigier Tshirt
and Jeans www.toptradea.com - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/29d609ef00194c2d?hl=en
* Nike Air Max, max 90, max 2009, max LTD, Nike Shox, Air force one Cheap
wholesale free shipping paypal payment (www.dotradenow.com.cn) - 1 messages, 1
author
http://groups.google.com/group/comp.lang.c++/t/451efb6a2d26a12f?hl=en
* Why do some code bases don't use exceptions? - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/c255001068888229?hl=en
* Segmentation fault but now errors when running Valgrind - 1 messages, 1
author
http://groups.google.com/group/comp.lang.c++/t/245ee50d3f1cbab8?hl=en
* Best practices for forward declaring a template function - 2 messages, 2
authors
http://groups.google.com/group/comp.lang.c++/t/9bcbaf09fcb855b8?hl=en

==============================================================================
TOPIC: C++ Middleware Writer version 1.10 is now on line
http://groups.google.com/group/comp.lang.c++/t/291ac5193f237b76?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Nov 28 2009 11:43 pm
From: Brian

Release 1.10 of the C++ Middleware Writer is now available
on line. This release has the following changes:

1. Support added for stream constructors. Previously types
were required to have default constructors in order to be
(de)marshalled by the C++ Midddle Writer. A function named
Receive was then called to demarshall the object. Below is
an example of how the code has changed in this area. The
old version is shown first with some added comments to
indicate how things have changed in the new version.

inline void
Base::BuildPolyInstance(Buffer* buf, Base*& p)
{
unsigned short type_num; // --> uint16_t

buf->PersistentRead(&type_num, sizeof(type_num));
switch (type_num) {
case Base_num:
p = new Base; // --> p = new Base(buf);
break;

case Derived_num:
p = new Derived; // --> p = new Derived(buf);
break;

default:
throw failure("Base::BuildPolyInstance: Unknown type");
}

p->Receive(buf); // This typically virtual function call
} // is no longer needed.

// new version as of release 1.10.
inline void
Base::BuildPolyInstance(Buffer* buf, Base*& p)
{
uint16_t type_num;

buf->PersistentRead(&type_num, sizeof(type_num));
switch (type_num) {
case Base_num:
p = new Base(buf);
break;

case Derived_num:
p = new Derived(buf);
break;

default:
throw failure("Base::BuildPolyInstance: Unknown type");
}
}


2. Support added for int8_t, int16_t, int32_t, uint8_t,
uint16_t and uint32_t.

3. The command line interface to the C++ Middleware Writer --
http://webEbenezer.net/build_integration.html -- has been
tested on a big-endian Mac. The program also works on
little-endian machines.

I'm interested in hearing what your thoughts are on the
C++ Middleware Writer.


Shalom
Brian Wood
http://webEbenezer.net

==============================================================================
TOPIC: Multiple inheritance and pointer equivalence
http://groups.google.com/group/comp.lang.c++/t/6ce10e4cd7c07869?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Nov 29 2009 12:50 am
From: "io_x"

"io_x" <a@b.c.invalid> ha scritto nel messaggio
news:4b10cc58$0$34589$4fafbaef@reader1.news.tin.it...
>> int main(void)
>> { C *c = new C;
>> A *a = c;
>> B *b = c;
>>
>> if(c->Aarr==0||c->Barr==0)
>> {P("No memory\n");
>> goto end;
>> }
>> printf("c: %p; a: %p; b: %p\n", c, a, b);
>> end:;
>> delete c;
>
> here seems that both each of "delete a" and "delete c"
^^^^^^^^

"delete b"

> is like "delete c"
>
>> P("END\n");
>> return 0;
>> }

==============================================================================
TOPIC: I don't have to tell you...
http://groups.google.com/group/comp.lang.c++/t/f615b948e5cca45b?hl=en
==============================================================================

== 1 of 4 ==
Date: Sun, Nov 29 2009 1:26 am
From: "Chris M. Thomasson"


"Joshua Maurice" <joshuamaurice@gmail.com> wrote in message
news:9e1954a5-d231-493d-bc17-9b55af272335@c3g2000yqd.googlegroups.com...
On Nov 28, 12:29 pm, Pavel
<pauldontspamt...@removeyourself.dontspam.yahoo> wrote:
> > BTW, I just found the reference to this article of Scott Meyers ibid in
> > Wikipedia:http://www.artima.com/cppsource/nevercall.html. I think
> > logically those who agree with this his opinion should agree to us
> > (Howard and myself) as well: what a point in having a "safety feature"
> > that is recommended to be used .. never?
> >
> > I say "logically" because Scott himself would apparently disagree:
> >
> > "... That's how every part of C++ will treat it, and the treatment makes
> > sense: the BuyTransaction-specific parts of the object haven't been
> > initialized yet, so it's safest to treat them as if they didn't exist".
> >
> > I, on the other hand, cannot see a big difference between calling any
> > function within a constructor (where some parts of an object may not
> > have been initialized yet) and calling a virtual function ibid. I
> > believe that treating the derived-class object as "non-existing" before
> > entering its construction function is an arbitrary and not very useful
> > choice of the Standard.

> Simple example.

> //
> #include <string>

> struct F
> {
> virtual std::string const& name() const =0;
> };
> struct G : F
> {
> std::string name_;
> virtual std::string const& name() const { return name_; }
> };
> //

> Now, if I wrote that sample correctly, let's look at F and G. Suppose
> F's constructor calls name() for debugging purposes. If it were to go
> to the most derived but not yet constructed object G, then it would
> return a reference to the not yet construct string sub-object, and any
> attempt to use it would probably crash because it's not initialized:
> the internal pointer of std::string would point to garbage and
> dereferencing it would crash or be equivalently bad. Moreover, if
> instead of string you had an object with virtual functions, then
> calling anything on it would be bad because it's virtual table has not
> yet been set up, so calling any virtual function on the sub-object
> would horribly fail.


FWIW, I have seen this type of error quite a few times when I am looking at
thread wrapper's implemented as a base class. The base class run's the
thread from the damn constructor, which in turn calls a pure virtual
function to invoke the derived class thread entry point. This is a major
race-condition. If the thread runs and calls that virtual function BEFORE
the derived class is FULLY constructed, BOOOOM! You're dead!


Here is a quick example:
__________________________________________________________________
#include <sched.h>
#include <pthread.h>
#include <cstdio>


#define YIELD sched_yield(), sched_yield(), sched_yield


extern "C" void* thread_base_entry(void*);


class thread_base
{
pthread_t m_tid;
virtual void on_entry() = 0;
friend void* thread_base_entry(void*);


public:
thread_base()
{
pthread_create(&m_tid, NULL, thread_base_entry, this);
YIELD(); // LOL!
}


void join()
{
pthread_join(m_tid, NULL);
}
};


void* thread_base_entry(void* state)
{
thread_base& this_ = *static_cast<thread_base*>(state);
this_.on_entry();
return NULL;
}


class foo : public thread_base
{
void on_entry()
{
std::puts("Hello from foo!");
}


public:
foo()
{
std::puts("Hello from foo's CTOR!");
}
};


int
main()
{
{
foo f;

f.join();
}

return 0;
}
__________________________________________________________________

This will probably crash, then again it might not because the whole thing is
a giant race condition.

What a MESS!

:^o

[...]

== 2 of 4 ==
Date: Sun, Nov 29 2009 2:29 am
From: Paavo Helde


"Alf P. Steinbach" <alfps@start.no> wrote in
news:hescsb$cvs$2@news.eternal-september.org:

> * Paavo Helde:
...
>> I think what he really wants is to define a function in derived
>> class, which can be called during construction and destruction of
>> base class. As such, this function cannot touch derived class data,
>> neither call other derived class functions which do this. This means
>> that the function effectively is a base class function, but defined
>> in the derived class, and presumably overrides some behavior of the
>> base class function having the samen name.
>>
>> I just gave a C++ implementation example of such a function in
>> another post.
>
> Uhm, this issue is covered in the FAQ.

Then it is strange that we have a 100+ message thread here about a topic in
FAQ....

Yes, I found something similar indeed in the end of FAQ 23.6 (but not
exactly). However, this section is so long and complicated that I'm afraid
many readers will skip it. If an innocent one-line question deserves a 10-
page answer in the FAQ, then maybe OP was right in that some more language
support would be helpful.

Paavo


== 3 of 4 ==
Date: Sun, Nov 29 2009 2:51 am
From: Paavo Helde


Paavo Helde <myfirstname@osa.pri.ee> wrote in
news:Xns9CD27F2CAA932paavo256@216.196.109.131:

> "Alf P. Steinbach" <alfps@start.no> wrote in
> news:hescsb$cvs$2@news.eternal-september.org:
>
>> * Paavo Helde:
> ...
>>> I think what he really wants is to define a function in derived
>>> class, which can be called during construction and destruction of
>>> base class. As such, this function cannot touch derived class data,
>>> neither call other derived class functions which do this. This means
>>> that the function effectively is a base class function, but defined
>>> in the derived class, and presumably overrides some behavior of the
>>> base class function having the samen name.
>>>
>>> I just gave a C++ implementation example of such a function in
>>> another post.
>>
>> Uhm, this issue is covered in the FAQ.
>
> Then it is strange that we have a 100+ message thread here about a
> topic in FAQ....
>
> Yes, I found something similar indeed in the end of FAQ 23.6 (but not
> exactly). However, this section is so long and complicated that I'm
> afraid many readers will skip it. If an innocent one-line question
> deserves a 10- page answer in the FAQ, then maybe OP was right in that
> some more language support would be helpful.

Ok, after reading some other OP responses I realize that he wants
something totally different - some kind of his own data structure, but
making use of C++ derivation syntax by unknown reasons. I'm afraid this
does not quite work out.

Regards
Paavo


== 4 of 4 ==
Date: Sun, Nov 29 2009 8:18 am
From: Krice


On 29 marras, 03:23, Howard Beale <n...@none.none> wrote:
> C++ is perfect and if you complain about it

You can complain about it until the end of days, but it
will not make you a better programmer. When you work with
language X it's obvious that you need to adapt to what the
creators of the language thought. If you can't do that,
try some other language. I have no difficulties with
C++, but then again I'm a genius, far superior than
average people.

==============================================================================
TOPIC: logging design question
http://groups.google.com/group/comp.lang.c++/t/003f14337480240c?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Nov 29 2009 3:14 am
From: Angus


Hello

I am building a C++ wrapper for a C API. So for example there is a
Widget object which encapsulates a Widget (obviously not called that).

There can be all sorts of reasons why getting/working with the widget
fails and I am wondering about logging the errors.

Should I:

A) have no logging in these classes and simply return error codes?
B have no logging and just raise an exception?
C) specify a logging path in constructor for object and log to there?

Angus

==============================================================================
TOPIC: Best way to search through STL maps?
http://groups.google.com/group/comp.lang.c++/t/7a79fbddf985eea2?hl=en
==============================================================================

== 1 of 3 ==
Date: Sun, Nov 29 2009 4:46 am
From: Steve


I have the following STL containers:

(using namespace std;)

typedef vector<string> TokenVector; // e.g [the] [cat] [sat] [on]
[the] [mat]

typedef map<TokenVector, long > NGramMap; // a list of unique n-grams
(as above), and a freq count.

My goal is to search for n-grams that match a pattern with wildcards,
for instance:

[the] [cat] [sat] [?] [the] [mat]

and return a list of all matches with all the possibilities for the
wildcard [?], along with the freq count

Assuming the map is sorted alphabetically, is there some way to search
them - like a regular expression - that return pattern matches?

The only way I can think of at the moment is to search for "[the]
[cat] [sat]", then sift through those matches.
This gets messy, though, when the pattern starts with a wildcard, or
contains 2 or 3 wildcards.

This seems like it might be a common task, so I thought I'd ask here
before re-inventing the wheel.
Does STL have ready-made solutions for this kind of search?

Does it make the problem any easier if it's constrained to _always_
being 6-grams, and that there are never more than 3 wildcards?

Thanks for any clues, even if it's just what topics I need to study in
order to crack it.

Steve


== 2 of 3 ==
Date: Sun, Nov 29 2009 11:37 am
From: er


Does the question boil down to finding whether

[the] [cat] [sat] [on] [the] [mat]

matches

[the] [cat] [sat] [?] [the] [mat]


where each of the above n-grams are represented by a collection of
strings and symbol ? is not a question mark but a wildcard?


== 3 of 3 ==
Date: Sun, Nov 29 2009 2:28 pm
From: Steve


On 29 Nov, 19:37, er <erwann.rog...@gmail.com> wrote:
> Does the question boil down to finding whether
>
> [the] [cat] [sat] [on] [the] [mat]
>
> matches
>
> [the] [cat] [sat] [?] [the] [mat]
>
> where each of the above n-grams are represented by a collection of
> strings and symbol ? is not a question mark but a wildcard?


Yes, succinctly put.

==============================================================================
TOPIC: Boost::unordered or boost::intrusive::hashtable
http://groups.google.com/group/comp.lang.c++/t/26a53a4fb9f6fad7?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Nov 29 2009 4:49 am
From: "carl"


I am looking for a hash-table implementation and have therefore looked at
boost. But it seems that its possible to choose some different versions. So
far I have found:

http://www.boost.org/doc/libs/1_35_0/doc/html/boost/intrusive/hashtable.html
http://www.boost.org/doc/libs/1_41_0/doc/html/unordered.html
http://www.boost.org/doc/libs/1_41_0/boost/multi_index_container.hpp

Which of the above version are best for supporting integer keys and values
which ar std::vectors and are there any examples showing how to use the
container?


==============================================================================
TOPIC: Disabling selected boost unit tests?
http://groups.google.com/group/comp.lang.c++/t/87a8fa20c5e6da69?hl=en
==============================================================================

== 1 of 2 ==
Date: Sun, Nov 29 2009 5:18 am
From: "carl"

"Gert-Jan de Vos" <gert-jan.de.vos@onsneteindhoven.nl> wrote in message
news:615f2601-352a-4e50-96d0-96295603874a@f16g2000yqm.googlegroups.com...
On Nov 28, 3:35 pm, "carl" <carl@.com> wrote:
> I have made a few boost unit-tests.
>
> #define BOOST_AUTO_TEST_MAIN
> #include <boost/test/auto_unit_test.hpp>
>
> // Boost Test declaration and Checking macros
> #include <boost/test/unit_test_suite.hpp>
> #include <boost/test/test_tools.hpp>
> #include <boost/test/floating_point_comparison.hpp>
>
> BOOST_AUTO_TEST_SUITE(my_tests);
> BOOST_AUTO_TEST_SUITE();
>
> BOOST_AUTO_TEST_CASE(test_1)
> {
>
> }
>
> BOOST_AUTO_TEST_CASE(test_2)
> {
>
> }
>
> BOOST_AUTO_TEST_CASE(test_3)
> {
>
> }
>
> Now when I run the unit-test all 3 test are executed. But is it possible
> somehow to specify that only test 2 should be run?

Run your test executable like this:

test --run_test=test_2

It is in "User's Guide" -> "Runtime configuration" -> "Run by name" in
the documentation.


Ok so its not possible to define a unit-test "main" function inside the
unit-test where the test to run is specified manually. I am using Visual
Studion and when I press run it automatically runs all the test. As an
alternative I can setup the run command to accept a runtime argument, but
its rather time consuming compared to outcomment a single line or two in the
source file.

== 2 of 2 ==
Date: Sun, Nov 29 2009 5:21 am
From: "carl"

"carl" <carl@.com> wrote in message
news:4b1274aa$0$273$14726298@news.sunsite.dk...
>
> "Gert-Jan de Vos" <gert-jan.de.vos@onsneteindhoven.nl> wrote in message
> news:615f2601-352a-4e50-96d0-96295603874a@f16g2000yqm.googlegroups.com...
> On Nov 28, 3:35 pm, "carl" <carl@.com> wrote:
>> I have made a few boost unit-tests.
>>
>> #define BOOST_AUTO_TEST_MAIN
>> #include <boost/test/auto_unit_test.hpp>
>>
>> // Boost Test declaration and Checking macros
>> #include <boost/test/unit_test_suite.hpp>
>> #include <boost/test/test_tools.hpp>
>> #include <boost/test/floating_point_comparison.hpp>
>>
>> BOOST_AUTO_TEST_SUITE(my_tests);
>> BOOST_AUTO_TEST_SUITE();
>>
>> BOOST_AUTO_TEST_CASE(test_1)
>> {
>>
>> }
>>
>> BOOST_AUTO_TEST_CASE(test_2)
>> {
>>
>> }
>>
>> BOOST_AUTO_TEST_CASE(test_3)
>> {
>>
>> }
>>
>> Now when I run the unit-test all 3 test are executed. But is it possible
>> somehow to specify that only test 2 should be run?
>
> Run your test executable like this:
>
> test --run_test=test_2
>
> It is in "User's Guide" -> "Runtime configuration" -> "Run by name" in
> the documentation.
>
>
>
>
> Ok so its not possible to define a unit-test "main" function inside the
> unit-test where the test to run is specified manually. I am using Visual
> Studion and when I press run it automatically runs all the test. As an
> alternative I can setup the run command to accept a runtime argument, but
> its rather time consuming compared to outcomment a single line or two in
> the source file.

Something like this:

http://www.ncbi.nlm.nih.gov/bookshelf/br.fcgi?book=toolkit&part=ch_boost#ch_boost.Disabling_Tests_Expl


Disabling Tests Explicitly in Code

The NCBI extensions include a macro, NCBITEST_DISABLE, to unconditionally
disable a test case or suite. This macro must be placed in the
NCBITEST_INIT_TREE function:
NCBITEST_INIT_TREE()
{
NCBITEST_DISABLE(test_case_name);
NCBITEST_DISABLE(test_suite_name);
}

==============================================================================
TOPIC: Discount Wholesale brand jeans wholesale free shipping : Affliction,
Armani Jeans,Christian Audigier, Coogi, G-STAR, Levi's, True Religion Jeans(
www.dotradenow.com.cn)
http://groups.google.com/group/comp.lang.c++/t/4b91fbe90654a642?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Nov 29 2009 5:34 am
From: NICEYOYO


Discount Wholesale Affliction Jeans <free shipping paypal payment>
Discount Wholesale AK Jeans ( www.dotradenow.com.cn )
Discount Wholesale Armani Jeans
Discount Wholesale Artful Dodger Jeans <free shipping paypal payment>
Discount Wholesale BAPE Jeans
Discount Wholesale BBC Jeans ( www.dotradenow.com.cn )
Discount Wholesale Black Label Jeans
Discount Wholesale Cavalli Jeans
Discount Wholesale Christian Audigier Jeans
Discount Wholesale Coogi Jeans
Discount Wholesale Crown Holder Jeans ( www.dotradenow.com.cn )
Discount Wholesale D&G Jeans
Discount Wholesale Diesel Jeans
Discount Wholesale ECKO Jeans ( www.dotradenow.com.cn )
Discount Wholesale ED Hardy Jeans
Discount Wholesale Evisu Jeans
Discount Wholesale G-STAR Jeans <free shipping paypal payment>
Discount Wholesale GUCCI Jeans
Discount Wholesale Iceberg Jeans
Discount Wholesale Kanji Jeans ( www.dotradenow.com.cn )
Discount Wholesale Laguna Beach Jeans
Discount Wholesale Levi s Jeans
Discount Wholesale LRG Jeans <free shipping paypal payment>
Discount Wholesale LV Jeans
Discount Wholesale Prada Jeans ( www.dotradenow.com.cn )
Discount Wholesale RMC Jeans
Discount Wholesale Roca Wear Jeans <free shipping paypal payment>
Discount Wholesale Rock&Republic Jeans
Discount Wholesale True Religion Jeans <free shipping paypal payment>
Discount Wholesale Versace Jeans
Discount Wholesale ZEN Jeans ( www.dotradenow.com.cn )

Belt
Discount Wholesale Armani Belt <free shipping paypal payment>
Discount Wholesale Bape Belt
Discount Wholesale BOSS Belt (www.dotradenow.com.cn)
Discount Wholesale Burberry Belt
Discount Wholesale CA Belt
Discount Wholesale Chanel Belt <free shipping paypal payment>
Discount Wholesale CK Belt
Discount Wholesale D&G Belt <free shipping paypal payment>
Discount Wholesale Diesel Belt
Discount Wholesale Dior Belt ( www.dotradenow.com.cn )
Discount Wholesale DSQ Belt
Discount Wholesale ED Belt ( www.dotradenow.com.cn )
Discount Wholesale Fendi Belt <free shipping paypal payment>
Discount Wholesale Gucci Belt
Discount Wholesale Hermes Belt ( www.dotradenow.com.cn )
Discount Wholesale Levi s Belt
Discount Wholesale LV Belt <free shipping paypal payment>
Discount Wholesale POLO Belt ( www.dotradenow.com.cn )
Discount Wholesale Prada Belt
Discount Wholesale Versace Belt <free shipping paypal payment>

Pants
Discount Wholesale A&F Pants <free shipping paypal payment>
Discount Wholesale Affliction Pants ( www.dotradenow.com.cn )
Discount Wholesale Bape Pants
Discount Wholesale Christian Audigier Pants ( www.dotradenow.com.cn )
Discount Wholesale COOGI Pants <free shipping paypal payment>
Discount Wholesale Crown Holder Pants
Discount Wholesale ED Hardy Pants ( www.dotradenow.com.cn )
Discount Wholesale Evisu Pants <free shipping paypal payment>
Discount Wholesale Discount Wholesale RMC Pants
Rock&Republic Pants ( www.dotradenow.com.cn )

==============================================================================
TOPIC: invalid covariant type / forward declaration?
http://groups.google.com/group/comp.lang.c++/t/e8bef11116736f7d?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Nov 29 2009 6:44 am
From: Michael Tsang


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Sybolt de Boer wrote:

> Robert Hairgrove wrote:
>
>> Sybolt de Boer wrote:
>>> Considering the following situation, is there a way to tell class White
>>> that a Black* is actually a valid Base*? In other words can I somehow
>>> forward declare "class Black : public Base;" in White.h and vice versa?
>>> Or am I trying to do something very bad and clearly illegal? :)
>>>
>>> TIA, Sybolt
>>>
>>> // Base.h
>>> #ifndef BASE_H
>>> #define BASE_H
>>> class Base {
>>> public:
>>> virtual Base *colleague(int i) const = 0;
>>> virtual Base *opponent(int i) const = 0;
>>> ....
>>> };
>>>
>>> // White.h
>>> #ifndef WHITE_H
>>> #define WHITE_H
>>> #include "Base.h"
>>>
>>> class White : public Base {
>>> public:
>>> White *colleague(int i) const { return White::create(i); }
>>> Black *opponent(int i) const { return Black::create(i); }
>>> static White *create(int i);
>>> ....
>>> };
>>>
>>> // Black.h
>>> #ifndef BLACK_H
>>> #define BLACK_H
>>> #include "Base.h"
>>>
>>> class Black : public Base {
>>> public:
>>> Black *colleague(int i) const { return Black::create(i); }
>>> White *opponent(int i) const { return White::create(i); }
>>> static Black *create(int i);
>>> ....
>>> };
>>>
>>
>> Move the function definitions into a .cpp file for each class. You will
>> also need to return Base* from both of the member functions in order for
>> it to work.
>
> Thanks for your reply. This is a heavily synthesized example. In reality
> the definitions are in a seperate source file. What I want is to preserve
> to color of the opponent, and not immediately degrade to a Base*. My
> compiler will allow me to include White.h in Black.h, or Black.h in
> White.h, but not both at the same time. I hope I'm making myself clear
> here. :)

I don't think this is possible. Black depends on White and White depends on
Black so you need to use a forward declaration. However, a forward
declaration cannot contain base specifier so covariant return type cannot be
applied.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAksSiOsACgkQG6NzcAXitM8qUwCeL9fWiG4JXscydl+F0Nl3+bxs
PjkAnimnhIyGGVC/W71f8FUxZcuVnRuy
=O6DU
-----END PGP SIGNATURE-----


==============================================================================
TOPIC: ♡*★*♡Wholesale NFL Arizona Caroinals,Baffalo-Bills,Chicago-Bears,Denver-
Broncos,Detroit-Lions,Houston-Texans,NewYork-Jets,Oakland-Raiders,SanDiego-
Chargers,etc
http://groups.google.com/group/comp.lang.c++/t/82c05842a979afde?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Nov 29 2009 7:34 am
From: "www.toptradea.com"


♡*★*♡Wholesale NFL Arizona Caroinals,Baffalo-Bills,Chicago-
Bears,Denver-Broncos,Detroit-Lions,Houston-Texans,NewYork-Jets,Oakland-
Raiders,SanDiego-Chargers,etc
"NFL-08All-Star-www.toptradea.com

NFL-Arizona-Caroinal-www.toptradea.com

NFL-Atlanta-Falcons-www.toptradea.com

NFL-Baffalo-Bills-www.toptradea.com

NFL-Baltimore-Ravens-www.toptradea.com

NFL-Carolina-Panther-www.toptradea.com

NFL-Chicago-Bears-www.toptradea.com

NFL-Cininnati-Bengal-www.toptradea.com

NFL-Cleveland-Browns-www.toptradea.com

NFL-Dallas-Cowboys-www.toptradea.com

NFL-Denver-Broncos-www.toptradea.com

NFL-Detroit-Lions-www.toptradea.com

NFL-Green-Bay-Packer-www.toptradea.com

NFL-Houston-Oilers-www.toptradea.com

NFL-Houston-Texans-www.toptradea.com

NFL-Indianapolis-Colts-www.toptradea.com

NFL-Jacksonville-Jaguars-www.toptradea.com

NFL-Kansas-City-Chiefs-www.toptradea.com

NFL-Miami-Dolphins-www.toptradea.com

NFL-Minnesota-Viking-www.toptradea.com

NFL-New-England-Patriots-www.toptradea.com

NFL-New-Orleans-Saints-www.toptradea.com

NFL-New-Yord-Giants-www.toptradea.com

NFL-NewYork-Jets-www.toptradea.com

NFL-Oakland-Raiders-www.toptradea.com

NFL-Philadelphia-Eagles-www.toptradea.com

NFL-Pittsburgh-Steel-www.toptradea.com

NFL-SanDiego-Charger-www.toptradea.com

NFL-SanFrancisco-49e-www.toptradea.com

NFL-Seattle-Seahawks-www.toptradea.com

NFL-St.Louis-Rams-www.toptradea.com

NFL-Tampa-Bay-Buccaneers-www.toptradea.com

NFL-Washington-Redskins-www.toptradea.com"

==============================================================================
TOPIC: HashTable
http://groups.google.com/group/comp.lang.c++/t/5a6dd10761e736f9?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Nov 29 2009 7:36 am
From: ram@zedat.fu-berlin.de (Stefan Ram)


"carl" <carl@.com> writes:
>When more that one object hash to the same index it gets added to a chain of
>elements. Are there any implmentations that returns the whole chain based on
>a hashed index?

Welcome to the world of "object-oriented programming" (or,
should I say just: "good practices of software engineering"?
or "abstract data types"?), here: "encapsulation" and
"information hiding"!

A "map" is defined as an object with an interface that
specifically does /not/ reveal this information. (For example,
so that it might change. In fact, a hash map might rehash its
entries sometimes so that also this chain will change.)


==============================================================================
TOPIC: ▧▤▨HOT SALE Brand Sunglasses Gucci,Chanel,DG,Armani,LV,Coach,Edhardy,
Burberry,Prada,Ferri etc Sunglasses WWW.toptradea.com
http://groups.google.com/group/comp.lang.c++/t/3970fe876e3728bd?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Nov 29 2009 7:36 am
From: "www.toptradea.com"


▧▤▨HOT SALE Brand Sunglasses
Gucci,Chanel,DG,Armani,LV,Coach,Edhardy,Burberry,Prada,Ferri etc
Sunglasses WWW.toptradea.com
"Sunglasses http://www.toptradea.com/
Okely Sunglasses http://www.toptradea.com

Adidas Sunglasses http://www.toptradea.com/

Armani Sunglasses http://www.toptradea.com/

Burberry Sunglasses http://www.toptradea.com/

Coach Sunglasses http://www.toptradea.com/

Chanel Sunglasses http://www.toptradea.com/

Dior Sunglasses http://www.toptradea.com/

D&G Sunglasses http://www.toptradea.com/

Gucci Sunglasses http://www.toptradea.com/

Edhardy Sunglasses http://www.toptradea.com/

LV Sunglasses http://www.toptradea.com/

Police Sunglasses http://www.toptradea.com/

Nike Sunglasses http://www.toptradea.com/

Prada Sunglasses http://www.toptradea.com/

Versace Sunglasses http://www.toptradea.com/
"

==============================================================================
TOPIC: ★→★→★→Sneaker Nike,Jordan,Gucci,Adidas,Puma,EdhardyShox,Max,Free,Rift
sneaker and Levis,Polo,Lacoste,BBC,Gucci,Armani,LV,Christina Audigier Tshirt
and Jeans www.toptradea.com
http://groups.google.com/group/comp.lang.c++/t/29d609ef00194c2d?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Nov 29 2009 7:38 am
From: "www.toptradea.com"


★→★→★→Sneaker Nike,Jordan,Gucci,Adidas,Puma,EdhardyShox,Max,Free,Rift
sneaker and Levis,Polo,Lacoste,BBC,Gucci,Armani,LV,Christina Audigier
Tshirt and Jeans www.toptradea.com
"Nike Air Jordan sneaker www.toptradea.com
Air-Jordan-J1 sneaker www.toptradea.com

Air-Jordan-J3 sneaker www.toptradea.com

Air Jordan J4 sneaker www.toptradea.com

Air Jordan J5 sneaker www.toptradea.com

Air Jordan J6 sneaker www.toptradea.com

Air Jordan J7 sneaker www.toptradea.com

Air Jordan J8 sneaker www.toptradea.com

Air Jordan J9 sneaker www.toptradea.com

Air Jordan J10 sneaker www.toptradea.com

Air Jordan 11 sneaker www.toptradea.com

Air Jordan J12 sneaker www.toptradea.com

Air Jordan J13 sneaker www.toptradea.com

Air Jordan J14 sneaker www.toptradea.com

Air Jordan J16 sneaker www.toptradea.com

Air Jordan J17 sneaker www.toptradea.com

Air Jordan J18 sneaker www.toptradea.com

Air Jordan J19 sneaker www.toptradea.com

Air Jordan J23 sneaker www.toptradea.com

Air Jordan J24 sneaker www.toptradea.com

Air Jordan J25 sneaker www.toptradea.com
Jordan True Flight sneaker www.toptradea.com

+Air Jordan Fusion sneaker www.toptradea.com
Air Jordan mix1257 sneaker www.toptradea.com

Air Jordan fly 45 sneaker www.toptradea.com

Air Jordan Anthony M sneaker www.toptradea.com

Air Jordan J1+AF1 sneaker www.toptradea.com

Air Jordan J1 23 sneaker www.toptradea.com

Air Jordan mix6 sneaker www.toptradea.com

Air Jordan mix sneaker www.toptradea.com

Air Jordan Mix9 sneaker www.toptradea.com

Air Jordan mix3 sneaker www.toptradea.com

Air Jordan J5 mixman sneaker www.toptradea.com

Air Jordan 6+AF1 sneaker www.toptradea.com

Air Jordan J11 mix6 sneaker www.toptradea.com

Air Jordan J11 23woman sneaker www.toptradea.com

Air Jordan J11 Obama sneaker www.toptradea.com

Air Jordan J11 Antho sneaker www.toptradea.com

Air Jordan J12mix sneaker www.toptradea.com

Air Jordan J13+16 sneaker www.toptradea.com

Jordan J13+AF1 new sneaker www.toptradea.com

Air Jordan J20AF1 sneaker www.toptradea.com

Air Jordan J23 mix sneaker www.toptradea.com
"
"Nike Air Max sneaker www.toptradea.com
Air Max 91 sneaker www.toptradea.com

Nike-ID sneaker www.toptradea.com

Air Max 87 sneaker www.toptradea.com

Air-Max-2003 sneaker www.toptradea.com

Air max 5 sneaker www.toptradea.com

Air-Max-Tailwind-09 sneaker www.toptradea.com

Air-Max-new-180 sneaker www.toptradea.com

Air-Max-LTD sneaker www.toptradea.com

Air-Max-2006 sneaker www.toptradea.com

Air Max 97 sneaker www.toptradea.com

Air Max 92 sneaker www.toptradea.com

Air Max 90 sneaker www.toptradea.com

Air-Max-Yeezy sneaker www.toptradea.com

Air Max 09 sneaker www.toptradea.com

Air-Max-TN sneaker www.toptradea.com

Air Jordan LTD2 sneaker www.toptradea.com

Air-Max-Skyline sneaker www.toptradea.com

Air-Max-miniBMW sneaker www.toptradea.com

Air-Max-2009 sneaker www.toptradea.com

Air-Max180 sneaker www.toptradea.com

Air Max 95 sneaker www.toptradea.com

+Nike Shox sneaker www.toptradea.com
Nike-shox-TR sneaker www.toptradea.com

Nike-shox-TL3 sneaker www.toptradea.com

Nike-shox-R3 sneaker www.toptradea.com
Nike-air-Plata sneaker www.toptradea.com

Nike-shox-new sneaker www.toptradea.com

Nike-shox-87 sneaker www.toptradea.com

Nike-shox-97 sneaker www.toptradea.com

Nike-shox-NZ sneaker www.toptradea.com

Nike-shox-R5 sneaker www.toptradea.com

Nike-shox-R4 sneaker www.toptradea.com

Nike-shox-TL1 sneaker www.toptradea.com

Nike-shox-OZ sneaker www.toptradea.com

Nike-shox-TZ sneaker www.toptradea.com

Nike-shox-torch sneaker www.toptradea.com

+Air Force 1 sneaker www.toptradea.com
Air-Force-1 sneaker www.toptradea.com

AF1-low-shoes sneaker www.toptradea.com

AF1-Supreme-TZ-man sneaker www.toptradea.com

+Nike Rift sneaker www.toptradea.com
Nike-Air-zenyth sneaker www.toptradea.com
Nike-Rift sneaker www.toptradea.com
"
"Asics causal shoes www.toptradea.com ,
Creative Recreation causal shoes www.toptradea.com ,
Coogi causal shoes www.toptradea.com ,
Clarks causal shoes www.toptradea.com ,
Dkny causal shoes www.toptradea.com ,
Hogan causal shoes www.toptradea.com ,
Supra causal shoes www.toptradea.com ,
DG causal shoes www.toptradea.com ,
Edhardy causal shoes www.toptradea.com ,
Lacoste causal shoes www.toptradea.com ,
Puma causal shoes www.toptradea.com ,
Coach causal shoes www.toptradea.com "

==============================================================================
TOPIC: Nike Air Max, max 90, max 2009, max LTD, Nike Shox, Air force one Cheap
wholesale free shipping paypal payment (www.dotradenow.com.cn)
http://groups.google.com/group/comp.lang.c++/t/451efb6a2d26a12f?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Nov 29 2009 8:08 am
From: tradeyoyo


Cheap Wholesale Shox NZ <www.dotradenow.com.cn> paypal payment
Cheap Wholesale Shox OZ <www.dotradenow.com.cn> free shipping
Cheap Wholesale Shox R2 <www.dotradenow.com.cn> paypal payment
Cheap Wholesale Shox R3 <www.dotradenow.com.cn> paypal payment
Cheap Wholesale Shox R3+R4 <www.dotradenow.com.cn> paypal payment
Cheap Wholesale Shox R4 <www.dotradenow.com.cn> paypal payment
Cheap Wholesale Shox R5 <www.dotradenow.com.cn> free shipping
Cheap Wholesale Shox Reverie lover
Cheap Wholesale Shox RZ <www.dotradenow.com.cn> paypal payment
Cheap Wholesale Shox TL <www.dotradenow.com.cn> free shipping
Cheap Wholesale Shox Torch <www.dotradenow.com.cn> paypal payment
Cheap Wholesale Shox TZ <www.dotradenow.com.cn> paypal payment

Cheap Wholesale Nike Air Max 87 <www.dotradenow.com.cn> free shipping
Cheap Wholesale Nike Air Max 89 <www.dotradenow.com.cn> paypal
payment
Cheap Wholesale Nike Air Max 90 <www.dotradenow.com.cn> paypal
payment
Cheap Wholesale Nike Air Max 91 <www.dotradenow.com.cn> free shipping
Cheap Wholesale Nike Air Max 92 Man <www.dotradenow.com.cn> paypal
payment
Cheap Wholesale Nike Air Max 93 <www.dotradenow.com.cn> paypal
payment
Cheap Wholesale Nike Air Max 95 <www.dotradenow.com.cn> free shipping
Cheap Wholesale Nike Air Max 97 <www.dotradenow.com.cn> paypal
payment
Cheap Wholesale Nike Air Max 180 Man <www.dotradenow.com.cn> paypal
payment
Cheap Wholesale Nike Air Max 2006 <www.dotradenow.com.cn> paypal
payment
Cheap Wholesale Nike Air Max 2009 <www.dotradenow.com.cn> paypal
payment
Cheap Wholesale Nike Air Max Clssic BW <www.dotradenow.com.cn> free
shipping
Cheap Wholesale Nike Air Max LTD <www.dotradenow.com.cn> paypal
payment
Cheap Wholesale Nike Air Max Skyline <www.dotradenow.com.cn> paypal
payment
Cheap Wholesale Nike Air Max STAB <www.dotradenow.com.cn> free
shipping
Cheap Wholesale Nike Air Max Tailwind <www.dotradenow.com.cn> paypal
payment
Cheap Wholesale Nike Air Max TN <www.dotradenow.com.cn> paypal
payment

Air Force one <www.dotradenow.com.cn> paypal payment
Cheap Wholesale Air Force One Man <www.dotradenow.com.cn> paypal
payment
Cheap Wholesale Air Force One Women <www.dotradenow.com.cn> paypal
payment
Cheap Wholesale Air Force One M&W <www.dotradenow.com.cn> paypal
payment
Cheap Wholesale Air Force one 25 Man <www.dotradenow.com.cn> paypal
payment
Cheap Wholesale Air Force One 25 Women <www.dotradenow.com.cn> paypal
payment
Cheap Wholesale Air Force One Kid <www.dotradenow.com.cn> paypal
payment
Cheap Wholesale Air Force one Mid Man <www.dotradenow.com.cn> paypal
payment
Cheap Wholesale Air Force one Mid Women <www.dotradenow.com.cn> paypal
payment
Cheap Wholesale Air Force one Hight Women <www.dotradenow.com.cn>
paypal payment

==============================================================================
TOPIC: Why do some code bases don't use exceptions?
http://groups.google.com/group/comp.lang.c++/t/c255001068888229?hl=en
==============================================================================

== 1 of 2 ==
Date: Sun, Nov 29 2009 9:44 am
From: White Wolf


Joshua Maurice wrote:
> On Nov 20, 8:09 pm, White Wolf <wo...@freemail.hu> wrote:
>> Paavo Helde wrote:
>>> Regarding Google, maybe they might have banned exceptions because of the
>>> run-time overhead (just guessing). Throwing exceptions is notoriously
>>> slow, so they should not be used unless something goes very wrong - but
>>> for a 24/7 service like Google nothing should go wrong ever, so no need
>>> for exceptions, right?
>> Notoriously slow is a pretty vague statement. Exceptions do not slower
>> the speed of the code unless they are thrown. So your choices are: slow
>> your happy code (that runs a billion times) by inserting hundreds of if
>> statements into it to propagate return codes up the call stack to the
>> handler, or make returning 1000 times slower 3 times a day... It is a
>> no brainer to me.
>
> Sadly no. That was the intent. However, on half of all of the unix-
> like environments available for me to test on, including Solaris, AIX,
> HPUX, Linux, and for the common windows platforms, win32, win64,
> exceptions add overhead even when not thrown, some worse than others.
> Windows, for example, implements C++ exceptions on top of their
> structured exception handling, which means that you're paying a
> penalty every time you enter a try block. For a particularly contrived
> test I once wrote, I got performance slowdowns of up to ~1.5x slower
> than the version which used error return codes on one platform.
>
> Not that I'm trying to say use exceptions or don't in this post. Just
> understand their practical costs and don't repeat (wishful)
> misinformation.

My tests on Linux, Windows and Solaris has shown different results than
yours.


== 2 of 2 ==
Date: Sun, Nov 29 2009 10:24 am
From: "Thomas J. Gritzan"


Joshua Maurice schrieb:
> On Nov 28, 8:56 am, "Thomas J. Gritzan" <phygon_antis...@gmx.de>
> wrote:
>> Joshua Maurice schrieb:
>>
>>> On Nov 27, 11:48 pm, Joshua Maurice <joshuamaur...@gmail.com> wrote:
>>> However, on half of all of the unix-
>>>> like environments available for me to test on, including Solaris, AIX,
>>>> HPUX, Linux, and for the common windows platforms, win32, win64,
>>>> exceptions add overhead even when not thrown, some worse than others.
>>> That should read "I have done tests on X platforms, and of those X,
>>> roughly half implement exceptions the slow aka bad aka not table way",
>>> not "The listed platforms are all bad." Some of the listed platforms
>>> implement exceptions the good way. See earlier posts. Sorry for the
>>> confusion.
>> You only have Win32 in your list, but not Win64 on either IA64 nor AMD64.
>>
>> Do you have numbers for those, too?
>
> Not offhand. I could run tests for them potentially when I get some
> spare time. I have been told or read that the win64 platform has a
> different ABI which handles exceptions different, the correct way,
> unlike win32.

I also read that the ABI changed to table-based exceptions in Windows
for AMD64. I guess they won't change it for Win32, as it would break
some code (or binary compatibility on library interfaces); and it
doesn't matter to them because too few customers use exceptions.

> I know nothing of win IA 64 or win AMD 64. .

You list lin 32, lin 64 and lin IA64, where uname says:
1) i386
2) x86_64
3) ia64

No. 1 is the known Intel x86 compatible desktop architecture.
No. 2 is the 64-bit extension of it developed by AMD and licensed by
Intel (sometimes called AMD64).
No. 3 is the 64-bit server architecture also known as Itanium.
Windows also runs on all three, and each is another platform on its own
with a different ABI. So it's ambiguous to say Win64, or "the 64-bit
Windows platform", as there are two.

--
Thomas

==============================================================================
TOPIC: Segmentation fault but now errors when running Valgrind
http://groups.google.com/group/comp.lang.c++/t/245ee50d3f1cbab8?hl=en
==============================================================================

== 1 of 1 ==
Date: Sun, Nov 29 2009 11:37 am
From: Ashu


On Nov 28, 4:23 pm, "carl" <carl@.com> wrote:
> "Ian Collins" <ian-n...@hotmail.com> wrote in message
>
> news:7ncc6uF3jv846U1@mid.individual.net...
>
> > carl wrote:
> >> I have made an application that throws a segmentation fault when I run
> >> it.
>
> >> ./MyApp
> >> Segmentation fault
>
> > What happens when you run the application under a debugger?
>
> > --
> > Ian Collins
>
> I have tried that but the error first appears when a subrutine is called
> after 20.000 to 30.000 iterations. I have made something like this:
>
> if (call_count < call_limit) {
>
>   //call the failing function
>   call_count++;
>
> }
>
> When I set call_limit is between 20.000 and 30.000 it works fine but it
> varies from call to call.
>
> One possible way would be to put a break inside the above if-statement and
> then have a starting count and a end count. But the interval would still be
> around a few thousands and my fingers will begin to bleed if I need to press
> the skip key in the debugger that many times.

hey, you might be using some other version of compiler dependent
library.
I faced some problem using libgcc3.2 earlier with my application and
it used to crash. I changed library and it works smooth.

==============================================================================
TOPIC: Best practices for forward declaring a template function
http://groups.google.com/group/comp.lang.c++/t/9bcbaf09fcb855b8?hl=en
==============================================================================

== 1 of 2 ==
Date: Sun, Nov 29 2009 12:11 pm
From: er


Hello,

Let's begin with a library that defines:

// A_HPP
namespace library{
class A{};
A::value_type foo(const A& a){...}
}
// B_HPP
namespace library{
class B{};
B::value_type foo(const B& b){...}

}

and I want to extend it, but non intrusively i.e. outside of namespace
library. I proceed like this:

template<typename T> struct is_library : mpl::false_{}; and for each X
in {A,B},

// FWD_A_HPP
#include A_HPP
template<> struct is_library<X> : mpl::true_;

// FWD_FOO
namespace extension{

typename lazy_enable_if<is_library<X>,mpl::identity<typename
X::value_type> >::type
foo(const X& x){
return library::foo(x)
}

}

And I then define my own classes :
// C_HPP
namespace extension{
struct C{};
typename C::value_type foo(const C& c){...};
}


The limitation of the above, to use it say in main.cpp, is that I have
to

#include FWD_A_HPP

before

#include FWD_FOO

Correct?

If the number of dependencies is large, keeping track of which files
comes before other becomes tedious so I guess the standard solution is
to add a forwarding declaration inside FWD_FOO,

namespace library{
typename A::value_type foo(const A& a);
}

just before extension::foo. Correct?

The problem is further complicated by the fact that A, B and C, in my
actual problem, have template e.g.
template<typename T> struct A;
template<typename T,typename U> struct B;

but the function signature is always
templat<typename X>
typename X::value_type foo(const X&);

On some compilers (MSVC), the above does not work. I get a compile
error : ambiguous call to overloaded function.

What is the best practice for this kind of problem?


== 2 of 2 ==
Date: Sun, Nov 29 2009 12:40 pm
From: "Alf P. Steinbach"


* er:
>
> Let's begin with a library that defines:
>
> // A_HPP
> namespace library{
> class A{};
> A::value_type foo(const A& a){...}
> }
> // B_HPP
> namespace library{
> class B{};
> B::value_type foo(const B& b){...}
>
> }

value_type is undefined.

Assuming you meant to define on in both class A and B.


> and I want to extend it, but non intrusively i.e. outside of namespace
> library. I proceed like this:
>
> template<typename T> struct is_library : mpl::false_{};
>
> and for each X in {A,B},
>
> // FWD_A_HPP
> #include A_HPP
> template<> struct is_library<X> : mpl::true_;
>
> // FWD_FOO
> namespace extension{
>
> typename lazy_enable_if<is_library<X>,mpl::identity<typename
> X::value_type> >::type
> foo(const X& x){
> return library::foo(x)
> }
>
> }

What's the point?


> And I then define my own classes :
> // C_HPP
> namespace extension{
> struct C{};
> typename C::value_type foo(const C& c){...};
> }

value_type is not defined.

There is no relation to the preceding explanation.


> The limitation of the above, to use it say in main.cpp, is that I have
> to
>
> #include FWD_A_HPP
>
> before
>
> #include FWD_FOO
>
> Correct?

No.


> If the number of dependencies is large, keeping track of which files
> comes before other becomes tedious so I guess the standard solution is
> to add a forwarding declaration inside FWD_FOO,
>
> namespace library{
> typename A::value_type foo(const A& a);
> }
>
> just before extension::foo. Correct?

Doesn't make sense so far.

> The problem is further complicated by the fact that A, B and C, in my
> actual problem, have template e.g.
> template<typename T> struct A;
> template<typename T,typename U> struct B;

So, now you're saying that all you've described so far has been *different* from
your problem.

> but the function signature is always
> templat<typename X>
> typename X::value_type foo(const X&);
>
> On some compilers (MSVC), the above does not work. I get a compile
> error : ambiguous call to overloaded function.

Error on line 42.


> What is the best practice for this kind of problem?

Check out the FAQ item on how to post a question about code that Does Not Work.


Cheers & hth.,

- Alf


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

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: