Monday, November 30, 2009

comp.lang.c++ - 26 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:

* fastest way to get a double from a string - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/d15c629d71fd2efc?hl=en
* Possible to call a function to "many" times? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/be1b60b85bd6e81b?hl=en
* Hot sale AAA real leather Handbags&purses Cheap Wholesale:Burberry, Chanel,
Chloe,Coach, D&G,Gucci, Jimmy Choo,Miumiu, LV etc (www.dotradenow.com.cn) - 1
messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/01eb91ff6a3e61ea?hl=en
* Healthy Mediterranean Diet - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/8b920b04498fdcab?hl=en
* ♠^o^♠^o^♠^o^♠Hot Sale Nike,Jordan,Gucci,Prada,Dior,Lacoste,Chanel,Coach,D&G,
Edhardy,Prada,UGG,Timberland,Supra shoes,sneaker,sandals… - 1 messages, 1
author
http://groups.google.com/group/comp.lang.c++/t/08960a419ee87860?hl=en
* ↖♡↗↖♡↗↖♡↗Fashion Handbags supplier www.toptradea.com Lady Handbags Juicy,
Gucci,LV,Prada,D&G,Edhardy,Chanel,Coach, Jimmy-Hoo,Burberry,DB - 1 messages, 1
author
http://groups.google.com/group/comp.lang.c++/t/10f5d2477199242f?hl=en
* ۞۞۞Whoelsale Brand new Nokia N97 and Apple Iphone 3Gs 16gb and 32gb, Iphone
3G mobiles - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/cd07a351b1583ed6?hl=en
* How to get an insertion hint for an unordered associated container? - 1
messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/21e47512ffcaf8a2?hl=en
* Best way to search through STL maps? - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/7a79fbddf985eea2?hl=en
* How can I sort this set? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/0bd32b5633e0030a?hl=en
* Article on possible improvements to C++ - 2 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/e46e9b3e07711d05?hl=en
* Order of destruction of static members and static objects - 2 messages, 1
author
http://groups.google.com/group/comp.lang.c++/t/8c6c8d00ec467068?hl=en
* friends, templates and comeau, gcc - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/99a5c9e8d832abcb?hl=en
* I don't have to tell you... - 2 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/f615b948e5cca45b?hl=en
* Shadowing template parameters - 5 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/1efc062271f57149?hl=en
* Christian Louboutin fashion shoes, Real leather Christian Louboutin Shoes
AAA quality Cheap sale (www.dotradenow.com.cn) - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/21ce0cc050b19e64?hl=en

==============================================================================
TOPIC: fastest way to get a double from a string
http://groups.google.com/group/comp.lang.c++/t/d15c629d71fd2efc?hl=en
==============================================================================

== 1 of 2 ==
Date: Sun, Nov 29 2009 11:03 pm
From: Kenshin


On Nov 30, 4:41 am, aaragon <alejandro.ara...@gmail.com> wrote:
> Hi everyone,
>
> I know that to obtain a double from a string, you can use something
> like the following (from the C++-FAQ):
>
>         template <typename T>
>         T stream_cast(std::string& s) {
>
>                 T x;
>                 static std::stringstream iss;
>                 iss.clear();
>                 iss.str(s);
>                 iss>>x;
>                 if (!iss) {
>                         std::string err("*** ERROR *** ");
>                         err += s + " cannot be converted to expected type with type id:\n";
>                         err += typeid(x).name();
>                         throw std::runtime_error(err);
>                 }
>                 return x;
>         }
>
> However, there has to be a faster way to accomplish this, and to fall
> back to this implementation if things don't go as expected. Is what
> I'm thinking possible? Could I use a try/catch block on the <cstdlib>
> function stof()?
>
> Thank you all,
>
> aa

std::string str("1.2");
double val = boost::lexical_cast<double>(str);

lexical_cast will be part of C++0x, so the below will be valid soon:

std::string str("1.2");
double val = std::lexical_cast<double>(str);


== 2 of 2 ==
Date: Mon, Nov 30 2009 5:59 am
From: Pete Becker


Kenshin wrote:
>
> lexical_cast will be part of C++0x
>

It's not there now, and I don't know of any plans to add it.

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of
"The Standard C++ Library Extensions: a Tutorial and Reference"
(www.petebecker.com/tr1book)

==============================================================================
TOPIC: Possible to call a function to "many" times?
http://groups.google.com/group/comp.lang.c++/t/be1b60b85bd6e81b?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Nov 30 2009 12:19 am
From: "Fred Zwarts"


carl <carl@.com> typed
(in 4b0ff3ae$0$275$14726298@news.sunsite.dk)
> "Richard Herring" <junk@[127.0.0.1]> wrote in message
> news:KkmaEMCVd6DLFwMh@baesystems.com...
>> In message <4b0ec973$0$277$14726298@news.sunsite.dk>, carl
>> <carl@?.com.invalid> writes
>>>
>>> I think I have come a bit closer to the problem:
>>>
>>> The function I call has the following declaration:
>>>
>>> /** Searches the neighbors fallen into a hypersphere */
>>> void Search(const MeasurementVectorType &query,
>>> double radius,
>>> InstanceIdentifierVectorType& result) const;
>>>
>>>
>>>
>>>
>>> From my function I call it like:
>>>
>>> VectorType vectorPoint;
>>> for (int i=0; i<NDimensions; i++) {
>>> vectorPoint[i] = point[i];
>>
>> Bzzzt. You haven't told us what VectorType is, or what the type of
>> point is, so how are we supposed to know whether vectorPoint[0]
>> actually exists? If VectorType is a typedef for
>> std::vector<something>, at this point you have an empty vector, so
>> vectorPoint[0] doesn't exist and assigning to it is undefined
>> behaviour.
>
>
>
> VectorType is:
>
> typedef Vector<TScalarType, SpaceDimension>
> VectorType;
>
>
> What do you mean that "vectorPoint[0] doesn't exist " ?
>
> When I do:
>
> VectorType vectorPoint;
>
> I create the vector. When I do:
>
> for (int i=0; i<NDimensions; i++) {
> vectorPoint[i] = point[i];
>
> each element from the point is copied to the vector. So that should
> work fine.

How can we know if you hide information?
First you don't tell what VectorType is.
Now we still don't know what Vector, TScalarType and SpaceDimension and NDimensions are.
If you say that it should work fine, what do you expect from us?
Should we trust you? OK, then it works fine, what is your problem?


==============================================================================
TOPIC: Hot sale AAA real leather Handbags&purses Cheap Wholesale:Burberry,
Chanel, Chloe,Coach, D&G,Gucci, Jimmy Choo,Miumiu, LV etc (www.dotradenow.com.
cn)
http://groups.google.com/group/comp.lang.c++/t/01eb91ff6a3e61ea?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Nov 30 2009 12:41 am
From: tradenow


Discount wholesale Handbags

AAA real leather Handbags http://www.dotradenow.com.cn/category-882-b0-AAA-True-Leather.html
Cheap Wholesale Balenciaga real leather Handbags
<www.dotradenow.com.cn paypal payment>
Cheap Wholesale Balenciaga real leather Purse
Cheap Wholesale Bally real leather Purse <free shipping paypal
payment>
Cheap Wholesale BOSS real leather Purse <www.dotradenow.com.cn paypal
payment>
Cheap Wholesale Burberry real leather Handbags
Cheap Wholesale Chanel real leather Handbags <free shipping paypal
payment>
Cheap Wholesale Chanel real leather Purse
Cheap Wholesale Chloe real leather Handbags
Cheap Wholesale Chloe real leather Purse <free shipping paypal
payment>
Cheap Wholesale Coach real leather Handbags
Cheap Wholesale Coach real leather Purse <www.dotradenow.com.cn paypal
payment>
Cheap Wholesale D&G real leather Handbags
Cheap Wholesale D&G real leather Purse
Cheap Wholesale Dior real leather Handbags <free shipping paypal
payment>
Cheap Wholesale Dunhill real leather Purse
Cheap Wholesale Fendi real leather Handbags <free shipping paypal
payment>
Cheap Wholesale Gucci real leather Handbags <www.dotradenow.com.cn
paypal payment>
Cheap Wholesale Gucci real leather Purse
Cheap Wholesale Hermes real leather Handbags
Cheap Wholesale Hermes real leather Purse <free shipping paypal
payment>
Cheap Wholesale Jimmy Choo real leather Handbags <free shipping paypal
payment>
Cheap Wholesale Jimmy Choo real leather Purse <free shipping paypal
payment>
Cheap Wholesale Juicy real leather Handbags <www.dotradenow.com.cn
paypal payment>
Cheap Wholesale Kooba real leather Handbags
Cheap Wholesale Lancel real leather Handbags
Cheap Wholesale Loewe real leather Handbags <www.dotradenow.com.cn
paypal payment>
Cheap Wholesale LV real leather Handbags <free shipping paypal
payment>
Cheap Wholesale LV real leather Purse <free shipping paypal payment>
Cheap Wholesale Marc Jacobs real leather Handbags
<www.dotradenow.com.cn paypal payment>
Cheap Wholesale Miumiu real leather Handbags
Cheap Wholesale Mulberry real leather Handbags
Cheap Wholesale Prada real leather Handbags <free shipping paypal
payment>
Cheap Wholesale Prada real leather Purse
Cheap Wholesale Thomaswlde real leather Handbags
<www.dotradenow.com.cn paypal payment>
Cheap Wholesale Valentnv real leather Handbags
Cheap Wholesale Versace real leather Handbags <www.dotradenow.com.cn
paypal payment>

A+ Grade
Purse http://www.dotradenow.com.cn/category-863-b0-Purse.html
Discount Wholesale Anna Purse <free shipping paypal payment>
Discount Wholesale Burbetty Purse
Discount Wholesale Chanel Purse <www.dotradenow.com.cn >
Discount Wholesale Chloe Purse
Discount Wholesale Coach Purse <www.dotradenow.com.cn >
Discount Wholesale D&G Purse
Discount Wholesale Dior Purse <www.dotradenow.com.cn >
Discount Wholesale Dooney&Bourke Purse
Discount Wholesale ED Hardy Purse <www.dotradenow.com.cn >
Discount Wholesale Fendi Purse
Discount Wholesale Ferragmo Purse
Discount Wholesale Gucci Purse <www.dotradenow.com.cn >
Discount Wholesale Guess Purse
Discount Wholesale LV Purse <free shipping paypal payment>
Discount Wholesale Miumiu Purse
Discount Wholesale Prada Purse <www.dotradenow.com.cn >
Discount Wholesale Tous Purse
Discount Wholesale Versace Purse <www.dotradenow.com.cn > <free
shipping paypal payment>
Handbags http://www.dotradenow.com.cn/category-843-b0-Handbag.html
Discount Wholesale BOSS Handbag
Discount Wholesale Burberry Handbag <www.dotradenow.com.cn >
Discount Wholesale CA Handbag
Discount Wholesale Chanel Handbag <free shipping paypal payment>
Discount Wholesale Chloe Handbag <www.dotradenow.com.cn >
Discount Wholesale Coach Handbag
Discount Wholesale D&G Handbag <www.dotradenow.com.cn >
Discount Wholesale Dooney&Bourke Handbag
Discount Wholesale ED Hardy Handbag <www.dotradenow.com.cn >
Discount Wholesale Fendi Handbag
Discount Wholesale Gucci Handbag <www.dotradenow.com.cn >
Discount Wholesale Hermes Handbag
Discount Wholesale Jimmy Choo Handbag <free shipping paypal
payment>
Discount Wholesale Juciy Handbag
Discount Wholesale LV Handbag <www.dotradenow.com.cn >
Discount Wholesale Miumiu Handbag <www.dotradenow.com.cn >
Discount Wholesale Prada Handbag
Discount Wholesale Tous Handbag <www.dotradenow.com.cn >
Discount Wholesale Versace Handbags <free shipping paypal payment>

==============================================================================
TOPIC: Healthy Mediterranean Diet
http://groups.google.com/group/comp.lang.c++/t/8b920b04498fdcab?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Nov 30 2009 12:56 am
From: Foodmatch

The mediterranean diet is strongly considered as healthy diet. This
diet preserves and re-vitalizes, within a modern lifestyle, centuries-
old customs (of or pertain to the Olive Growing Nations) that
contribute to excellent health and a wonderful sense of pleasure and
well-being.

http://www.foodmatch.com/mediterranean-diet.aspx

==============================================================================
TOPIC: ♠^o^♠^o^♠^o^♠Hot Sale Nike,Jordan,Gucci,Prada,Dior,Lacoste,Chanel,Coach,
D&G,Edhardy,Prada,UGG,Timberland,Supra shoes,sneaker,sandals…
http://groups.google.com/group/comp.lang.c++/t/08960a419ee87860?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Nov 30 2009 1:21 am
From: "www.toptradea.com"


♠^o^♠^o^♠^o^♠Hot Sale
Nike,Jordan,Gucci,Prada,Dior,Lacoste,Chanel,Coach,D&G,Edhardy,Prada,UGG,Timberland,Supra
shoes,sneaker,sandals…
"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 "
"Adidas Shoes sneaker www.toptradea.com
Adidas-Good-Year sneaker www.toptradea.com

Adidas-Good-Year2 sneaker www.toptradea.com

+Puma Shoes sneaker www.toptradea.com
Puma-woman-shoes sneaker www.toptradea.com

Puma-man-shoes sneaker www.toptradea.com

Puma-centennial sneaker www.toptradea.com

Puma sneaker www.toptradea.com

Puma-6 sneaker www.toptradea.com

Puma-new sneaker www.toptradea.com

Puma-Kimi-Rainkkonen sneaker www.toptradea.com

Puma-Anniversary sneaker www.toptradea.com

Puma-8813 sneaker www.toptradea.com

Puma-5 sneaker www.toptradea.com

+Nike Blazer sneaker www.toptradea.com
Nike-Blazer sneaker www.toptradea.com

+Edhardy Shoes sneaker www.toptradea.com
man-shoes sneaker www.toptradea.com

canvas-low-shoes sneaker www.toptradea.com

woman-shoes sneaker www.toptradea.com

Casual-shoes sneaker www.toptradea.com

canvas-high-shoes sneaker www.toptradea.com

+Gucci Shoes sneaker www.toptradea.com
Gucci-size14 sneaker www.toptradea.com

Man-low-shoes sneaker www.toptradea.com

woman-high-shoes sneaker www.toptradea.com

Gucci-shoes-A sneaker www.toptradea.com

Man-high-shoes sneaker www.toptradea.com

woman-low-shoes sneaker www.toptradea.com

+Lacoste Shoes sneaker www.toptradea.com
Lacoste-woman-shoes sneaker www.toptradea.com

Lacoste-man-shoes sneaker www.toptradea.com

Lacoste-white-man sneaker www.toptradea.com
+Prada Shoes sneaker www.toptradea.com
Prada-shoes sneaker www.toptradea.com

+Chanel Shoes sneaker www.toptradea.com
Chanel woman shoes sneaker www.toptradea.com

+Coach Shoes sneaker www.toptradea.com
Coach-woman-shoes sneaker www.toptradea.com

Coach-man-shoes sneaker www.toptradea.com

+D&G Shoes sneaker www.toptradea.com "

==============================================================================
TOPIC: ↖♡↗↖♡↗↖♡↗Fashion Handbags supplier www.toptradea.com Lady Handbags
Juicy,Gucci,LV,Prada,D&G,Edhardy,Chanel,Coach, Jimmy-Hoo,Burberry,DB
http://groups.google.com/group/comp.lang.c++/t/10f5d2477199242f?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Nov 30 2009 1:22 am
From: "www.toptradea.com"


↖♡↗↖♡↗↖♡↗Fashion Handbags supplier www.toptradea.com Lady Handbags
Juicy,Gucci,LV,Prada,D&G,Edhardy,Chanel,Coach, Jimmy-Hoo,Burberry,DB
"Handbag {www.toptradea.com }
Burberrys Handbag {www.toptradea.com }

Prada Handbag {www.toptradea.com }


Juicy Handbag {www.toptradea.com


Ed hardy Handbag {www.toptradea.com }


DB Handbag {www.toptradea.com }


Chloe Handbag {www.toptradea.com }


LV Handbag {www.toptradea.com }


Jimmy Hoo Handbag {www.toptradea.com }


Fendi Handbag {www.toptradea.com }


Coach Handbag {www.toptradea.com }


Gucci Handbag {www.toptradea.com }


Chanel Handbag {www.toptradea.com }


D&G Handbag {www.toptradea.com }

"
"Suite [www.toptradea.com ]
Adidas-suits[www.toptradea.com ]

Bape-suit[www.toptradea.com ]

Juicy-suits[www.toptradea.com ]

Nike-suit[www.toptradea.com ]
"
"Sandal {www.toptradea.com}
D&G-Sandals {www.toptradea.com}

Dior-Sandals {www.toptradea.com}

EdHardy-slipper {www.toptradea.com}

Gucci-sandal {www.toptradea.com}

LV-Sandals {www.toptradea.com}
"
"Jacket www.toptradea.com
Adidas-Jacket www.toptradea.com

Bape-Jacket www.toptradea.com

BBC-Jacket www.toptradea.com

Burberrry-Jacket www.toptradea.com

EdHardy-Jacket www.toptradea.com

CA-Jacket www.toptradea.com

Gstar-Jackets www.toptradea.com

Gucci-Jacket www.toptradea.com

Lacost-Jacket www.toptradea.com"
"Wallets www.toptradea.com
Chanel-Wallets www.toptradea.com

Coach-Wallets www.toptradea.com

D&G-Wallets www.toptradea.com

DB-Wallets www.toptradea.com

Gucci-Wallets www.toptradea.com

Juicy-Wallets www.toptradea.com

LV-Wallets www.toptradea.com

Versace-Wallets www.toptradea.com"

==============================================================================
TOPIC: ۞۞۞Whoelsale Brand new Nokia N97 and Apple Iphone 3Gs 16gb and 32gb,
Iphone 3G mobiles
http://groups.google.com/group/comp.lang.c++/t/cd07a351b1583ed6?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Nov 30 2009 1:23 am
From: "www.toptradea.com"


۞۞۞Whoelsale Brand new Nokia N97 and Apple Iphone 3Gs 16gb and 32gb,
Iphone 3G mobiles
"Apple [www.toptradea.com ]
Nokia [www.toptradea.com ]
Blackberry [www.toptradea.com ]
Samsung [www.toptradea.com ]
Sony Ericsson [www.toptradea.com ]
HTC [www.toptradea.com ]
"

==============================================================================
TOPIC: How to get an insertion hint for an unordered associated container?
http://groups.google.com/group/comp.lang.c++/t/21e47512ffcaf8a2?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Nov 30 2009 1:36 am
From: James Kanze


On Nov 27, 9:24 pm, Pavel
<pauldontspamt...@removeyourself.dontspam.yahoo> wrote:
> James Kanze wrote:
> > On Nov 27, 4:30 am, Pavel
> > <pauldontspamt...@removeyourself.dontspam.yahoo> wrote:
> >> James Kanze wrote:
> >>> On Nov 24, 5:24 am, Pavel
> >>> <pauldontspamt...@removeyourself.dontspam.yahoo> wrote:
> >>>> James Kanze wrote:
> >>>>> On Nov 21, 8:34 pm, Pavel

> >>> [...]
> >>> Most of the hash maps I've written in the past would cache
> >>> the last element found, in order to support things like:

> >>> if ( m.contains(x) ) {
> >>> m[x] = 2*m[x] ; // or whatever...
> >>> }

> >> I understand you can optimize the set for the usage pattern
> >> you think is common. This comes at cost even for this use,
> >> however, as the comparision may be much more expensive than
> >> hash-function computation and you guarantee you will have an
> >> extra comparison in m[x] at all times. We know we can do
> >> without (see above) so why should we live with it.

> > It's a common usage pattern with my hashed containers: since
> > [] has a precondition that the entry exists,

> You mean -- in your container, not STL?

Yes.

> I don't like STL's inserting things into maps behind my back
> either, e.g.:

> std::map<int, int> m;
> int i = m[5];
> /* it's not exactly intuitive that we have just created a (5, 0) entry
> on the map.. */

My earliest versions of a hash table did this as well---they
were based on my experience with AWK. (In fact, I've come to
the conclusion that it's a very bad idea. AWK and C++ are
different languages, and what's the best solution in one isn't
necessarily a good solution in the other.) But even then, I
found myself often using contains to avoid accidentally
inserting a new element. All too often, you need to procede
differently depending on whether the element is present or not.

> That's why I mostly use explicit insert, find etc.

Agreed. I've found almost no use for std::map's operator[]
either. I rather think it was an afterthought---that the design
itself is to use find for access, and insert for insertion, and
that operator[] was added with an AWK-like semantic as a
convenience function, for the cases where you need or want an
AWK-like semantic.

If you use find and insert, then of course, there's no point in
caching the last value, since the iterator find returns contains
it. I have a lot of code along the lines of:

Map::const_iterator elem = map.find(key);
return elem == map.end()
? someDefaultValue
: elem->second;

With my earlier implementations, this was:

return map.contains(key)
? map[key]
: someDefaultValue;

(which I still prefer, but the STL usage above is more than
acceptable as well).

> > [...]
> >> The cost of insertion can be anything -- in case of
> >> conflict it may even be some secondary hash or linear or
> >> non-linear search in the overflow area or similar. The
> >> Standard does not define how exactly the overflows are
> >> processed.

> > It does require buckets, since it exposes this detail at the
> > interface level. The guarantees with regards to this part
> > of the interface are rather vague, but I would expect that
> > if (double)(m.bucket_count()+1)/m.size()<
> > m.max_load_factor(), then:
> > size_t b = m.bucket(obj);
> > m.insert(obj);
> > assert(b == m.bucket(obj));

> My reading is opposite:

> It says (1) "Keys with the same hash code appear in the same
> bucket" and (2) "The number of buckets is automatically
> increased as elements are added to an unordered associative
> container"

> So, if there is one bucket now, m.bucket(obj) has to return 0;
> if there must be two buckets after after the insertion as per
> (2), the inserted element may have gone to the bucket 1 with
> other its peers (the bucket may contain elements with more
> than one hash code it is just that if two elements have same
> hash code they must appear in the same bucket per (1) so if
> obj had hashcode 2 and 0th bucket contained all elements with
> codes 1 and 2, all twos may need to go to the 1st bucket
> during the insertion).

That's why I had the precondition.

As I said, I don't think this is 100% clear in the draft, but
you do have "The number of buckets is automatically increased as
elements are added to an unordered associative container, so
that the average number of elements per bucket is kept below a
bound. Rehashing invalidates iterators, changes ordering between
elements, and changes which buckets elements appear in, but does
not invalidate pointers or references to elements." There seems
(to me, at least) to be a strong presumption that if you don't
rehash, iterators aren't invalidated, and that the container
doesn't rehash unless it needs to, so that you can count on
iterators not being invalidated if you can ensure that the load
factor will not be exceeded. I may be reading too much into
this, since I don't see any practical way of guaranteeing a
sufficient number of buckets beforehand; e.g. something like
reserve in std::vector. Something like:
map.max_load_factor(0.5F);
map.rehash();
map.max_load_factor(0.8F);
would probably work in practice, but I'm not sure that it is
guaranteed. (The argument of max_load_factor is only a hint.
From a QoI point of view, I would expect that it result in a
max_load_factor <= the given value, and I don't understand the
standard not requiring it.) I think some function along the
lines of reserve or reserve_buckets would be in order---if I
know I'm going to insert 100000 elements, it's rather a bother
not to be able to tell the hash table this beforehand, so that
it doesn't have to rehash.

--
James Kanze

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

== 1 of 2 ==
Date: Mon, Nov 30 2009 1:42 am
From: Steve


On 29 Nov, 23:00, er <erwann.rog...@gmail.com> wrote:
> On Nov 29, 5:28 pm, Steve <petertwoca...@googlemail.com> wrote:
>
> > 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.
>
> I have a feeling (yes, nothing more reliable than that as I don't deal
> text processing) that working with strings might be easier than
> breaking them into tokens that are held by a STL container. And do so
> using C++ I would look into Boost.Regex. But probably you already
> thought of this and have a good reason to use tokens.

Yes, but having still found no shortcuts, I'm beginning to think that
keeping composite string copies for searching is the way to go.
(I really should investigate Boost, but a quick search reveals people
having nightmares building it for OSX due to the transition to 64-bit,
so I'll have to hold off for a while.)

Thanks

Steve


== 2 of 2 ==
Date: Mon, Nov 30 2009 6:18 am
From: er


> (I really should investigate Boost, but a quick search  reveals people
> having nightmares building it for OSX due to the transition to 64-bit,
> so I'll have to hold off for a while.)

FYI I was able to build a couple of the boost libraries (the bulk of
boost does not need installing) on Snow Leopard (64-bit). Some of the
searches you found probably pertain to advanced features that you
probably don't need.

==============================================================================
TOPIC: How can I sort this set?
http://groups.google.com/group/comp.lang.c++/t/0bd32b5633e0030a?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Nov 30 2009 1:44 am
From: James Kanze


On Nov 27, 11:12 pm, Sam <s...@email-scan.com> wrote:
> petertwocakes writes:
> As such the correct prototype for a comparison object [for an
> std::set< TokenVector >], that you intend to use with your
> actual set should be:

> bool operator()(const TokenVector &a, const TokenVector &b) const;

> It's arguable whether or not the comparison operator should be
> a constant function, or not.

It a requirement that the comparison operator be a constant
function, since std::set will call it on a copy which is a
component of the set object, and you want to be able to be able
to call const functions (like set<>::find) on the set.

--
James Kanze

==============================================================================
TOPIC: Article on possible improvements to C++
http://groups.google.com/group/comp.lang.c++/t/e46e9b3e07711d05?hl=en
==============================================================================

== 1 of 2 ==
Date: Mon, Nov 30 2009 1:46 am
From: Nick Keighley


On 28 Nov, 00:42, Paavo Helde <myfirstn...@osa.pri.ee> wrote:
> NickKeighley<nick_keighley_nos...@hotmail.com> wrote innews:808cc67a-f8ce-4db4-bcf2-65897d504e17@d10g2000yqh.googlegroups.com:
> > On 21 Nov, 00:02, Paavo Helde <myfirstn...@osa.pri.ee> wrote:

<snip>

> >> [...] all exceptions propagating
> >> out of a library should be derived from std::exception.
>
> > which rules out using much of boost
>
> Like which? All Boost exceptions I have seen have been derived from
> std::exception. But I admit I have used only a few libraries.

I'd encountered something called boost::exception which didn't derive
from std::exception. Reading the boost documentation more closely it
appears you are supposed (or encouraged) to derive from both std:: and
boost:: exception.


> >> In my experience, most exceptions finally get logged as a text, or
> >> displayed to the end user as a text.
>
> > not in mine. many exceptions are swallowed silently. Even if they are
> > reported to a log file that isn't the primary reason for the
> > exception. Think automatic invocation of dtors and passing control
> > back up the stack.
>
> This is even easier. If you are using a particular exception type, you
> can throw and catch it exactly in the points you like.

Oh I know I was just pointing out the rasion d'etre of exceptions was
*not* to produce a human readable message.

> This has nothing
> to do with the original problem raised up in the thread, at least not as
> far as I have understood, namely that by using multiple libraries one
> often does not know exactly which exceptions might arise, and how to deal
> with them.

you'd hope the library would document it somehow.


> Obivously, if you are using a custom exception just to wind up
> the stack, this is no problem.

whats the difference between a "library exception" and a "custom
exception"

> >> So what I need is just to convert every exception to text.
>
> > use what()
>
> Yes, if the exception is derived from std::exception. It gets more
> difficult when it isn't.

there's all sorts of nasty things people do. I liked the one that made
all the exception data private. With no access methods. Were you
supposed to trap it in the debugger?

<snip>


> >> Having special exception types only comes handy when they are used
> >> for handling special situations near the throw point. But this should
> >> not be visible to other libraries and should not cause combinatorial
> >> explosion.
>
> > define "near". What if I want to [break? (I've no idea what word I meant to use here!)]
> > out of some deeply nested
> > transaction? The call can't proceed and all the associated resources
> > need to be freed- some of which are actually physical resources like
> > radio channels or comms links.
>
> This is fine, and this is exactly what exceptions are meant for.
>
> What I meant by "near" was that it should be in borders of a single
> library,

I don't agree


> or more generally in the borders of code you directly control.
> If the exception passes through another library which you don't have much
> control over, it might not get through reliably.

It will if the library is written sanely. Don't catch anything you
don'ty know how to handle [The Ferret Catchers Handbook]

> It can be swallowed or
> translated to another exception type (if not today, then in the next
> version). In your own library you can modify all intermediate catch
> blocks (if there are any!) to let this special exception propagate
> through untouched, until the proper handling point is reached.


== 2 of 2 ==
Date: Mon, Nov 30 2009 2:11 am
From: Nick Keighley


On 27 Nov, 10:59, "Balog Pal" <p...@lib.hu> wrote:
> "NickKeighley" <nick_keighley_nos...@hotmail.com>

<snip>

> >> OTOH, the real way to make correct code is definitely not going by that
> >> info but through using consistent RAII-like handling, and reviews enforcing
> >> it.
>
> >I keep on seeing things like this. How exactly does RAII deal with
> >allocations that don't follow a simple [stack based] model?
>
> Insert some example of the model you think problematic.

anything that doesn't follow a stack model. A graphical editor. A
mobile phone system. You are at the mercy of the end user as to when
objects are created and destroyed. With the phone system people can
drive into tunnels or JCBs (back-hoes) can dig up comms links (that
really happened once).


> >> As test runs will hardly cover all possible paths including errors and
> >> exceptions, so relying on the empty leak list from a random run is
> >> nothing but illusion of being okay. While with trivial style it is easy
> >> to make leaks impossible.
>
> >so explain to me how I trivially remove all possible memory leaks from
> >my programs.
>
> "Remove" is not the way.  You start from nothing -- that is assumed
> leak-free ;-)  and add all the stuff in a way that can't leak.  So your
> program is always leak-free.

ah, my computer science lecturer used to tell us that a blank piece of
paper had no bugs. Programmers then just went on to add bugs.


> The style is like:
>  - 'delete' is forbidden in "client" code.  It is privilige of the the few
> library classes that serve as managers.   Like auto_ptr.

and who holds the auto-ptr?

>  - The result of every new goes immediately to one such manager.

> That's about it.

these things always seem to solve the easy cases (ok they used to be
the very hard cases!) but not the hard cases.


>  Certainly there are a few cases where ownership is
> transferred --

a few!


> so look what happens to result of release(), Detach() and
> similar calls, that is IME natural.
>
> Same thing applies to other resources: files, handles, GDI resources, locks,
> transactions.

except for transactions, yes

> As an example, you may look some old Petzold examples to struggle with raw
> WIN API in pure C -- and see how the same thing looks using MFC's   CFont,
> CBrush and similar wrappers.  

I've wrappered Win32 in C++. Yes, RAII makes life easier.


> The difference is incredible in readability
> and clearness.  As a side effect DBWIN no longer explodes on any random
> program reporting a zillion of lost resources.
>
> If you want a very simple example,

no, I don't want a simple example


> think a program that processes text
> manipulating strings all its time.  A C++ solution would use std::string,
> (or any of the much better string classes).  Doing all the passing-around,
> cutting, concatenating, etc.

consider a text editor that allows the user to delete text. Who
deletes the string that holds the deleted stuff and when. What if the
editor has Undo/Redo?

> Without having a single new or other allocation in the *client* code of the
> program.

the client code is gonna have to do something to trigger the new. Call
a factory for instance.

> While obvoiusly doing a zillion alllocations and deallocations.
> Can you describe a way to introduce a leak?

forget to call the thing that triggers the delete.


> >> Why invest in better patches instead of cure the problem at roots?
>
> >because you can't remove the problem at its root. If you want true
> >dynamic allocation then you need to trigger delete somehow. Unless you
> >add garbage collection to C++.
>
> Sure you can, and many of us do it in practice.  C++ has destructors that
> are called automaticly at well defined points

the points are not always so well defined.


> -- and that automation can
> reliably be used to do the deletes you need.   All of them.
>
> As, unless you start doing WTF things deliberately just to prove idiots'

I'm not *trying* to break things.


> endless resources, destructors will be called matching constructors, and
> when leaving a scope by *any* means.    

but leaving scope is *not* the correct time to delete some objects!

CallManager::process_event (EventAP event)
{
CallAP call = 0;

if (is_new_call (event))
{
call = CallFactory::create_call (event);
CallList::add_call (call);
}
else
{
CallAp call = CallList::lookup_call (event);
}

call.process_event(event);
}

when this finishes the call should very definitly not be destroyed!
The CallManager (or some class this is delegated to has to track what
goes into CallList (the list of currently active calls) and also be
careful about rmoving things from it- when they are destroyed.

> So the programmer's responsibility
> is just to not leave non-managed resources around.

oh, *that* all!


> (Certainly for certain tasks you can insert GC too, I didn;t work with such
> problem yet, but read success stories.)

I've never used garbage collection in C++ either.


--
Nick Keighley

The world you perceive is drastically simplified model of the real
world
(Herbert Simon)

==============================================================================
TOPIC: Order of destruction of static members and static objects
http://groups.google.com/group/comp.lang.c++/t/8c6c8d00ec467068?hl=en
==============================================================================

== 1 of 2 ==
Date: Mon, Nov 30 2009 1:50 am
From: James Kanze


On Nov 28, 3:36 pm, Juha Nieminen <nos...@thanks.invalid> wrote:
> James Kanze wrote:
> > That's often the simplest and most appropriate solution. If
> > Container is a more general class (e.g. an std::vector),
> > then you can wrap it in a simple function to ensure the same
> > behavior. Another solution is to ensure that Container has
> > a trivial destructor.

> How can you implement safely something like this?

> // Header file
> // -----------
> class A
> {
> static std::vector<int> sharedContainer;

> A(const A&);
> A& operator=(const A&);

> public:
> A();
> ~A();
> };

> // Source file
> // -----------
> std::vector<int> A::sharedContainer;

> A::A() { sharedContainer.push_back(0); }
> A::~A() { sharedContainer.pop_back(); }

> If somewhere else you have something like:

> namespace { A a; }

> then the constructor might be accessing an unconstructed
> std::vector, and the destructor might be accessing a destroyed
> std::vector.

Yes. And the push_back/pop_back mean that you can't use int[]
and static initialization:-).

> Construction safety could be ensured by changing the container to:
>
> namespace
> {
> std::vector<int>& sharedContainer()
> {
> static std::vector<int> container;
> return container;
> }
> }

> But does that ensure that it's not accessed after it has been
> destroyed? If not, how do you make sure it's not?

std::vector< int >&
sharedContainer()
{
static std::vector< int >* theOneAndOnly = new std::vecctor< int >;
return *theOneAndOnly;
}

The standard singleton idiom, in fact.

--
James Kanze


== 2 of 2 ==
Date: Mon, Nov 30 2009 1:54 am
From: James Kanze


On Nov 28, 3:26 pm, Juha Nieminen <nos...@thanks.invalid> wrote:
> Victor Bazarov wrote:
> > Apparently you need 'A::container' to be a singleton. See
> > any of the existing implementations of that pattern. Most
> > simple ones actually create the singleton on demand (in
> > freestore) and never destroy it.

> You mean that if you want to make sure that a static member is
> never accessed after it has been destroyed, you have to
> allocate it dynamically and purposefully leak it?

That's the usual singleton idiom.

> Doesn't that make static members a bit useless?

Not really. At the application level, there are any number of
classes which simply can't be used before entering main (for
various reasons), and for which all instances will be destructed
before leaving main. No problem with static members here. It
generally only gets tricky for library code (where you don't
really know where it will be used), or a few special application
level classes.

--
James Kanze

==============================================================================
TOPIC: friends, templates and comeau, gcc
http://groups.google.com/group/comp.lang.c++/t/99a5c9e8d832abcb?hl=en
==============================================================================

== 1 of 2 ==
Date: Mon, Nov 30 2009 3:58 am
From: werasm


Hi all,

I have this (minimal) piece of code that does not compile under comeau
(online) and gcc 4.2.1.

namespace n{

template <class T> struct X
{
friend int foo( X ){ return 0; }
};

}//!n

int main()
{
n::X<int> x;
return n::foo( x );
}

Comeau output:

"ComeauTest.c", line 15: error: namespace "n" has no member "foo"
return n::foo( x );

When removing the namespace qualification, everything compiles fine,
therefore...
[...as before...]
int main()
{
n::X<int> x;
return foo( x );
}

...now compiles without errors.

Changing the example slightly to here below:

namespace n{

template <class T> class X;

template <class T> int foo( X<T> )
{ return 0; }

template <class T>
struct X
{
friend int foo<>( X<T> );
};

}//!n

int m()
{
n::X<int> x;
return n::foo( x );
}

Does not result in the error (irrespective of whether n is qualified
or not). I have not checked gcc with respect to this.

Can anybody perhaps give an explanation concerning this behaviour. Is
this perhaps a compiler bug?

Kind regards,

Werner


== 2 of 2 ==
Date: Mon, Nov 30 2009 4:50 am
From: "Balog Pal"


"werasm" <werasm@gmail.com>

> I have this (minimal) piece of code that does not compile under comeau
> (online) and gcc 4.2.1.
>
> namespace n{
>
> template <class T> struct X
> {
> friend int foo( X ){ return 0; }
> };
>
> }//!n
>
> int main()
> {
> n::X<int> x;
> return n::foo( x );
> }
>
> Comeau output:
>
> "ComeauTest.c", line 15: error: namespace "n" has no member "foo"
> return n::foo( x );

This looks a tricky one. 11.4p5 states

A function can be defined in a friend declaration of a class if and only if
the class is a nonlocal class (9.8), the function name is unqualified, and
the function has namespace scope. [Example:

class M {

friend void f() { } // definition of global f, a friend of M,

// not the definition of a member function

};

-end example] Such a function is implicitly inline. A friend function
defined in a class is in the (lexical) scope of the class in which it is
defined. A friend function defined outside the class is not (3.4.1).


What means you shouldn't see foo from main in any case. Only in member
functions of x. I triec cameau, and you indeed can use foo there, but only
unqualified. n::foo there gives the same error. I'm not sure whether that
is supposed to happen or not, for practical reasons it hardly matters.


>
> When removing the namespace qualification, everything compiles fine,
> therefore...
> [...as before...]
> int main()
> {
> n::X<int> x;
> return foo( x );
> }
>
> ...now compiles without errors.

If you use ::foo in this case it is correctly reported as not there.
If you make foo use different arguments, it is also not there.

So it seem to be found by ADL somehow (unless really a bug) -- I leave that
part of explanation to someone else ;-)) certainly that can only apply
without qualification.

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

== 1 of 2 ==
Date: Mon, Nov 30 2009 4:11 am
From: "Christopher Dearlove"


"Pavel" <pauldontspamtolk@removeyourself.dontspam.yahoo> wrote in message
news:008d46ef$0$23362$c3e8da3@news.astraweb.com...
> void say(const char *msg) { cout << msg << '\n'; }
>
> class Object {
> public:
> Object() { say(name()); }
> virtual const char *name() {return "Object";}
> };
>
> class Foo : public Object {
> public:
> const char *name() { return "Foo"; }
> };
>
> class Bar : public Object {
> public:
> const char *name() { return "Bar"; }
> };
>
> int main() { Foo o; Bar o1; return 0; }

class Object
{
public:
explicit Object(const char * name) { say(name); }
};

class Foo : public Object
{
public:
Foo() : Object("Foo") {}
};

class Bar : public Object
{
public:
Bar() : Object("Bar") {}
};

or if you prefer

class Foo : public Object
{
public:
Foo() : Object(name()) {}
static const char * name() { return "Foo"; }
};


== 2 of 2 ==
Date: Mon, Nov 30 2009 4:28 am
From: "Christopher Dearlove"


"Christopher Dearlove" <chris.dearlove@baesystems.com> wrote in message
news:4b13b64c$1_1@glkas0286.greenlnk.net...
> "Pavel" <pauldontspamtolk@removeyourself.dontspam.yahoo> wrote in message
> news:008d46ef$0$23362$c3e8da3@news.astraweb.com...
>> void say(const char *msg) { cout << msg << '\n'; }
>>
>> class Object {
>> public:
>> Object() { say(name()); }
>> virtual const char *name() {return "Object";}
>> };
>>
>> class Foo : public Object {
>> public:
>> const char *name() { return "Foo"; }
>> };
>>
>> class Bar : public Object {
>> public:
>> const char *name() { return "Bar"; }
>> };
>>
>> int main() { Foo o; Bar o1; return 0; }
>
> class Object
> {
> public:
> explicit Object(const char * name) { say(name); }
> };
>
> class Foo : public Object
> {
> public:
> Foo() : Object("Foo") {}
> };
>
> class Bar : public Object
> {
> public:
> Bar() : Object("Bar") {}
> };
>
> or if you prefer
>
> class Foo : public Object
> {
> public:
> Foo() : Object(name()) {}
> static const char * name() { return "Foo"; }
> };

Following myself up, or if you really want to:

typedef const char * (* Name)();

class Object
{
public:
explicit Object(Name name) { say(name()); }
};

class Foo : public Object
{
public:
Foo() : Object(name) {}
static const char * name() { return "Foo"; }
};

==============================================================================
TOPIC: Shadowing template parameters
http://groups.google.com/group/comp.lang.c++/t/1efc062271f57149?hl=en
==============================================================================

== 1 of 5 ==
Date: Mon, Nov 30 2009 4:39 am
From: Stuart Golodetz


Hi,

Just a quick question - I was wondering if there's any reason why you're
not allowed to shadow template parameters?

e.g.

template <typename T>
struct S
{
typedef T T;
};

I've found it to be quite a useful way of providing access to the
template parameter in certain cases, e.g.

template <typename U>
void f(U u)
{
// e.g. If an S<int> is passed in, we can use typename U::T to
// access the int template parameter
}

VC++ 2005 (apparently incorrectly) allows me to do it, but it gets
flagged up as an error when I compile the same code with g++ (Comeau
also has a problem with it, so I strongly suspect g++ is getting it
right). Is there an alternative way to achieve the same thing without
renaming either the template parameter or the typedef? And is there a
reason why this should be impossible?

Cheers,
Stu


== 2 of 5 ==
Date: Mon, Nov 30 2009 5:24 am
From: "Balog Pal"


"Stuart Golodetz"
> Hi,
>
> Just a quick question - I was wondering if there's any reason why you're
> not allowed to shadow template parameters?
>
> e.g.
>
> template <typename T>
> struct S
> {
> typedef T T;
> };

IMO you can, at a nested scope. On the same level you can't because
identifier T is already taken. Use a different name.
typedef T FirstArg;

> I've found it to be quite a useful way of providing access to the template
> parameter in certain cases, e.g.
>
> template <typename U>
> void f(U u)
> {
> // e.g. If an S<int> is passed in, we can use typename U::T to
> // access the int template parameter
> }

Then you can do that.

> VC++ 2005 (apparently incorrectly) allows me to do it, but it gets flagged
> up as an error when I compile the same code with g++

It probably follows from the relax rule of VC that allows "redundant"
typedefs (multiple typedefs to the same name, until they all refer to the
same type).

> (Comeau also has a problem with it, so I strongly suspect g++ is getting
> it right). Is there an alternative way to achieve the same thing without
> renaming either the template parameter or the typedef?

Why is that a problem? Change your code at one place:

template <typename T1>
struct S
{
typedef T1 T;
};

and all the rest shall work fine. (I'm guessing without try...)

But T is just a name you created, what is so special about it? Meanwhile it
is not part of anything beyond the block right after it -- i.e.

template <typename T>
struct S
{
void foo();
};

template <typename T1> // can use any name, and T has no meaning...
void S<T1>::foo() {}

== 3 of 5 ==
Date: Mon, Nov 30 2009 5:27 am
From: Stuart Golodetz


Balog Pal wrote:
> "Stuart Golodetz"
>> Hi,
>>
>> Just a quick question - I was wondering if there's any reason why
>> you're not allowed to shadow template parameters?
>>
>> e.g.
>>
>> template <typename T>
>> struct S
>> {
>> typedef T T;
>> };
>
> IMO you can, at a nested scope. On the same level you can't because
> identifier T is already taken. Use a different name.
> typedef T FirstArg;
>
>> I've found it to be quite a useful way of providing access to the
>> template parameter in certain cases, e.g.
>>
>> template <typename U>
>> void f(U u)
>> {
>> // e.g. If an S<int> is passed in, we can use typename U::T to
>> // access the int template parameter
>> }
>
> Then you can do that.
>
>> VC++ 2005 (apparently incorrectly) allows me to do it, but it gets
>> flagged up as an error when I compile the same code with g++
>
> It probably follows from the relax rule of VC that allows "redundant"
> typedefs (multiple typedefs to the same name, until they all refer to
> the same type).

Ok, makes sense.

>> (Comeau also has a problem with it, so I strongly suspect g++ is
>> getting it right). Is there an alternative way to achieve the same
>> thing without renaming either the template parameter or the typedef?
>
> Why is that a problem? Change your code at one place:
>
> template <typename T1>
> struct S
> {
> typedef T1 T;
> };
>
> and all the rest shall work fine. (I'm guessing without try...)

You also have to change it for all the function definitions, which is a
mild pain - but it's not impossible to change, you're right. I was just
wondering why it was necessary really.

> But T is just a name you created, what is so special about it?
> Meanwhile it is not part of anything beyond the block right after it --
> i.e.
>
> template <typename T>
> struct S
> {
> void foo();
> };
>
> template <typename T1> // can use any name, and T has no meaning...
> void S<T1>::foo() {}

This is basically what I've ended up doing (e.g. in an image class, I'm
using PixelType within the class and Pixel as the public typedef) - but
it just seems slightly unnecessary.

No worries, anyway :-)
Stu


== 4 of 5 ==
Date: Mon, Nov 30 2009 5:32 am
From: "Balog Pal"


"Stuart Golodetz"
>>> (Comeau also has a problem with it, so I strongly suspect g++ is
>>> getting it right). Is there an alternative way to achieve the same
>>> thing without renaming either the template parameter or the typedef?
>>
>> Why is that a problem? Change your code at one place:
>>
>> template <typename T1>
>> struct S
>> {
>> typedef T1 T;
>> };
>>
>> and all the rest shall work fine. (I'm guessing without try...)
>
> You also have to change it for all the function definitions

Why?


== 5 of 5 ==
Date: Mon, Nov 30 2009 5:44 am
From: Stuart Golodetz


Balog Pal wrote:
> "Stuart Golodetz"
>>>> (Comeau also has a problem with it, so I strongly suspect g++ is
>>>> getting it right). Is there an alternative way to achieve the same
>>>> thing without renaming either the template parameter or the typedef?
>>>
>>> Why is that a problem? Change your code at one place:
>>>
>>> template <typename T1>
>>> struct S
>>> {
>>> typedef T1 T;
>>> };
>>>
>>> and all the rest shall work fine. (I'm guessing without try...)
>>
>> You also have to change it for all the function definitions
>
> Why?

Actually you're right, aren't you? :-) Silly me. Ok, maybe I'm whipping
up a storm in a teacup in that case.

Cheers,
Stu

==============================================================================
TOPIC: Christian Louboutin fashion shoes, Real leather Christian Louboutin
Shoes AAA quality Cheap sale (www.dotradenow.com.cn)
http://groups.google.com/group/comp.lang.c++/t/21ce0cc050b19e64?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Nov 30 2009 5:53 am
From: tradenow


Cheap Wholesale Gucci Shoes (paypal payment)
(www.dotradenow.com.cn )
Cheap Wholesale GUCCI Boots
Cheap Wholesale Lacoste Shoes
Cheap Wholesale LV Shoes (paypal payment)
(www.dotradenow.com.cn )
Cheap Wholesale LV Boots
Cheap Wholesale Prada Shoes (paypal payment)
(www.dotradenow.com.cn )
Cheap Wholesale Timberland Shoes
Cheap Wholesale D&G Shoes (paypal payment)
(www.dotradenow.com.cn )
Cheap Wholesale D&G Boots
Cheap Wholesale Puma Shoes
Cheap Wholesale Puma AAA (paypal payment)
(www.dotradenow.com.cn )
Cheap Wholesale UGG Boots Shoes
Cheap Wholesale Bikkem Bergs Shoes (free shipping)
Cheap Wholesale Mauri Shoes Man
Cheap Wholesale Versace Shoes (paypal payment)
(www.dotradenow.com.cn )
Cheap Wholesale Versace Boots
Cheap Wholesale Paul Smith Shoes (free shipping)
Cheap Wholesale BOSS Shoes
Cheap Wholesale Burberry Shoes (paypal payment)
(www.dotradenow.com.cn )
Cheap Wholesale Dsquared shoes
Cheap Wholesale Dior Shoes (free shipping)
Cheap Wholesale Dior Boots
Cheap Wholesale ED Hardy Shoes (paypal payment)
(www.dotradenow.com.cn )
Cheap Wholesale ED Hardy Boots
Cheap Wholesale ED Hardy Shoes Man (paypal payment)
(www.dotradenow.com.cn )
Cheap Wholesale Fendi Shoes (paypal payment)
(www.dotradenow.com.cn )
Cheap Wholesale Fendi Boots
Cheap Wholesale AFF Shoes (paypal payment)
(www.dotradenow.com.cn )
Cheap Wholesale Evisu Shoes (free shipping)
Cheap Wholesale 4US Shoes
Cheap Wholesale Sebago Shoes (paypal payment)
(www.dotradenow.com.cn )
Cheap Wholesale Supra Shoes
Cheap Wholesale Hight Converse Shoes (paypal payment)
(www.dotradenow.com.cn )
Cheap Wholesale Coach Boots
Cheap Wholesale Coach Shoes
Women Christian Louboutin (paypal payment)
(www.dotradenow.com.cn )
Cheap Wholesale Chanel Shoes
Cheap Wholesale Chanel Boots (free shipping)
Cheap Wholesale Bape Shoes
Cheap Wholesale Adidas Shoes (paypal payment)
(www.dotradenow.com.cn )
Cheap Wholesale Adicolor (free shipping)
Cheap Wholesale Adidas 35TH (paypal payment)
(www.dotradenow.com.cn )
Cheap Wholesale Adidas NBA
Cheap Wholesale Adidas Running (paypal payment)
(www.dotradenow.com.cn )
Cheap Wholesale Adidas Y3
Cheap Wholesale Soccer Shoes (paypal payment)
(www.dotradenow.com.cn )


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

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: