Monday, November 30, 2009

[jQuery] jQuery Interacting with database

Hi

I have a small doubt in jQuery.Is it possible to directly interact
with the database without going to the server side(php,jsp,servlet
etc) and do addition,deletion,modification of rows of a particular
table.I am looking at this scenario so as to speed up the query,reduce
overload etc.Kindly reply

Regards
Umadas

[jQuery] Two dimensional arrays and $.post

Hi list,

I need to dynamically create an associative array in jquery, then pass
it to a php script for processing (using the $.post method), in order
to receive a value of some sort.

The array is generated every time the user performs a change in a
select list element, and is of the following structure:
myArray = [ ID => value, ID => value, ..., ID => value]

My questions:
- How can I define an associative array?
- How can I pass it on a php script using $.post?

Thanks in advance!

St

[jQuery] Re: Best Practices or unobtrusive Javascript

On Nov 30, 10:32 am, Andre Polykanine <an...@arthaelon.net> wrote:
> I prefer to put JS in header, also. But I read somewhere that there is
> a bug dealing with an interference of PHP's $variables and jQuery
> $-notation, so it's suggested to put the jQuery functions into the
> body and not into the head section. Is it true?

I don't do much PHP these days, but when I do, I've never run across
such a bug. I suppose that if you use double-quoted strings in PHP to
generate JavaScript output, then you would need to escape the "$", but
I don't do that anyway.

-- Scott

[jQuery] Looking for term in JSON

What I have currently is once the page loads the wordStats goes out
and counts the words and then it takes them and we use the most
popular to pull information from a JSON file.

The problem is that if it does not find the most popular word then it
just gives off an error and I am not sure how to provided it with a
default value.

I have pasted my code below along with a sample of my JSON.

Thanks.
<script language="javascript" type="text/javascript">
$(function() {
var count = 3;

$.extend($.wordStats.stopWords, {'retrieved': true,
'2007': true});

$.wordStats.computeTopWords(count);

for(var i = 0, j = $.wordStats.topWords.length; i < j && i
<= count; i++) {

var $type = $.wordStats.topWords[0].substring(1);

}

$.getJSON('test.json',function(data) {

$.each(data[$type], function(key,state) {

alert(state);

});
});

$.wordStats.clear();
});
</script>

//// JSON

{
'corvair' :
{ 'corvair' : 'Corvairs are fun!'},
'default' :
{'default' : 'Default Text'}
}

[jQuery] Validate: a question about the Remote option

Hello everyone,

I'm still dealing with that signup form.
Now I'd like to check with an Ajax call if a login is already taken.
That's what I'm doing:

$("#signup").validate( {
rules: {
ulogin: {
required: true,
// It's a custom method checking a regexp, it's working
login: true,
rangelength: [3,20],
remote: "check.php?w=1"
},
...

Here's the check.php file:

// Including the connection file, blah blah
...
$valid=true;
// Since I'm planning to use this file as a multipurpose script,
//preventing it from stop working
if (!isset($_REQUEST['w'])) $_REQUEST['w']=1;
if ($_REQUEST['w']==1) {
// If the login is taken, it will return something >0
$number=mysql_num_rows(mysql_query("SELECT `Id` FROM `Users` WHERE `Login`='".$_REQUEST['ulogin']."'", $link));
if ($number>0) $valid=false; else $valid=true;
}
After I validate, it stops working: it says incorrect for all fields
after the second submit. After the first submit it says nothing, even
that the login is already taken.
What's wrong?
Thanks!

--
With best regards from Ukraine,
Andre
Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @ jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: m_elensule

[jQuery] get random record?

Has anyone come across a simple function that will get a random record from the db?
 
I just need to send a request every min or so to get new content from the db and change the content. Pretty much like a banner rotator but used for random content.
 
thanks,
 
Dave

Re: [jQuery] Jquery specialist for hire

I'll do it for $5. paypal: laces210@gmail.com
email me at: jerryhost.com@gmail.com

[jQuery] Form Plugin Double Submit

Hello, I have a problem with the jQuery Form Plugin. I add the:
$myForm.ajaxForm(options);
but when submitting this calls twice the beforeSubmit and success. I
only call the ajaxForm once when added the element.
The url is: http://grupotakami.webfactional.com/es_bueno/9/ if you
wanna give it a try.

Thanks,

Davsket

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

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

comp.lang.c++@googlegroups.com

Today's topics:

* Best way to search through STL maps? - 4 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/7a79fbddf985eea2?hl=en
* friends, templates and comeau, gcc - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/99a5c9e8d832abcb?hl=en
* AutoFlowchart : auto generate flowchart from source code - 1 messages, 1
author
http://groups.google.com/group/comp.lang.c++/t/5616ce70ade5faed?hl=en
* fastest way to get a double from a string - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/t/d15c629d71fd2efc?hl=en
* Order of destruction of static members and static objects - 5 messages, 4
authors
http://groups.google.com/group/comp.lang.c++/t/8c6c8d00ec467068?hl=en
* WWW.TOTRADEA.COM ★NO.1 Quality★ Wholesale Handbags, Edhardy,Gucci,Chanel,LV,
Juicy,UGG,Prada,Coach,D&G,Fendi handbags - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/c23dc88002d330d0?hl=en
* ★→Iphone 3GS and 3G,Nokia N97,N96,Blackberry 9500,9000 fashion mobiles, New,
unlocked,one year warranty - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/7a66459a6e89a7d3?hl=en
* =♡*★*♡=HOT SALE Nike,Jordan,Shox,Max,Dunk,Gucci,Supra,Edhardy,Lacoste,Adidas,
Prada,Doir,Lanvin,Hogan sneakers - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/a10d063258c67743?hl=en
* Looking for a good memory and CPU profiler - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/ac40d4006ea2c71c?hl=en
* Cheap Wholesale& Retail GHD discount GHD straightener (www.dotradenow.com.cn)
- 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/8f0a7c92d1acebaa?hl=en
* Article on possible improvements to C++ - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/e46e9b3e07711d05?hl=en
* how to achieve low latency in C++ - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/a27acf7c042642e9?hl=en
* What is fastest? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/917a17e130cd2dc9?hl=en

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

== 1 of 4 ==
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.


== 2 of 4 ==
Date: Mon, Nov 30 2009 7:46 am
From: Jeff Flinn


Steve wrote:
> 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.)

Did you mean this:

> it was reported that in Snow Leopard, Apple has removed support for
> ppc64, and folks trying to use that receive fairly obscure errors.
> Some of Boost users were already confused by this. Now, this is
> of course more like Apple's problem, but here's a patch, against
> current trunk, to do a nice diagnostic of this in Boost.Build.
> The intention is that if you try to build just ppc64, or a two-way
> fat binary including ppc64 you get an error message, and if you
> try tobuild 4-way fat binary, ppc64 is skipped and you get 3-way
> binary.

Jeff


== 3 of 4 ==
Date: Mon, Nov 30 2009 8:43 am
From: Steve


On 30 Nov, 15:46, Jeff Flinn <TriumphSprint2...@hotmail.com> wrote:
> Steve wrote:
> > 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.)
>
> Did you mean this:
>
>  > it was reported that in Snow Leopard, Apple has removed support for
>  > ppc64, and folks trying to use that receive fairly obscure errors.
>  > Some of Boost users were already confused by this. Now, this is
>  > of course more like Apple's problem, but here's a patch, against
>  > current trunk, to do a nice diagnostic of this in Boost.Build.
>  > The intention is that if you try to build just ppc64, or a two-way
>  > fat binary including ppc64 you get an error message, and if you
>  > try tobuild 4-way fat binary, ppc64 is skipped and you get 3-way
>  > binary.
>
> Jeff

Yes, not that exact message, but the gist of it. Well, it looks like
it's worth persevering then.


== 4 of 4 ==
Date: Mon, Nov 30 2009 10:17 am
From: er

> >  > it was reported that in Snow Leopard, Apple has removed support for
> >  > ppc64, and folks trying to use that receive fairly obscure errors.
> >  > Some of Boost users were already confused by this. Now, this is
> >  > of course more like Apple's problem, but here's a patch, against
> > Jeff
>
> Yes, not that exact message, but the gist of it. Well, it looks like
> it's worth persevering then.

Does ppc64 concern you? Not me, so I did not need a patch.

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

== 1 of 3 ==
Date: Mon, Nov 30 2009 6:21 am
From: "Johannes Schaub (litb)"


werasm wrote:

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

This is how it is supposed to work. You have to differentiate:

- Introducing a name into a declarative region.
- Introducing a *visible* name into a declarative region.
- Putting a declaration directly into a declarative region.

Visibility is a property of names that make them visible to unqualified name
lookup (a name can be hidden when doing "inside out" lookup, from nested
regions to outer regions).

Normally, declarations introduce visible names into a declarative region
(namespace body, class body, ...). Certain declarations introduce names, but
the name is not visible when looked up in that declarative region:

void f() { extern int a; /* visible here */ }
void g() { a; /* error: 'a' not visible */ }
void h() {
extern float a; /* error: a introduced as int variable already */
}
extern float a; /* same error */
extern int a; /* alright, now it's visible ("in scope") from here */

A friend declaration acts similar, as it introduces a name not into the
region the declaration appears in, but into the nearest enclosing namespace
scope, as a not visible name:

struct A { friend void f(); friend void g(); };
int main() { f(); } // error: f not visible
int g(); // error: void g(); and int g(); not overloadable

That was unqualified name lookup without considering ADL (argument dependent
lookup). ADL says:

"When an unqualified name is used as the postfix-expression in a function
call (5.2.2), other namespaces not considered during the usual unqualified
lookup (3.4.1) may be searched, and namespace-scope friend function
declarations (11.4) not otherwise visible may be found."

You may wonder how it knows "f()" is a function call, even though it doesn't
yet know that "f" is a function: This is because every other syntax that
matches "f()" is constrained: "f" needs to be a type name, for instance (see
3.4.1/3). But as a function call, we don't need constraints. Now, the friend
declaration within the class' declarative region that declared a namespace
scope function is considered in addition and is visible to ADL, since a
function argument of your call was a class that contained that declaration.

That was the unqualified case. If you consider qualified-lookup into a
namespace, like "n::f", then it will lookup in declarations that occured in
that namespace (and as a special case, considering using-directives too
("using namespace ...")). However, your friend declaration appeared not in
that namespace, and you did not have an explicit declaration of it in that
namespace. Thus, there is no declaration found.

== 2 of 3 ==
Date: Mon, Nov 30 2009 9:27 am
From: werasm


On Nov 30, 4:21 pm, "Johannes Schaub (litb)" <schaub-johan...@web.de>
wrote:

> This is how it is supposed to work. You have to differentiate:
>
> - Introducing a name into a declarative region.
> - Introducing a *visible* name into a declarative region.
> - Putting a declaration directly into a declarative region.

OK


> A friend declaration acts similar, as it introduces a name not into the
> region the declaration appears in, but into the nearest enclosing namespace
> scope, as a not visible name:

Therefore:

Defining a friend inside a class introduces the name into the
declarative region of the nearest inclosing namespace scope, but as an
invisible name that is only found by ADL (and cannot be found when
qualified).

Do you have any idea why they would want to make it invisible (in the
enclosing namespace scope) in the first place (as a matter of
interest)? i.e. Is it beneficial in any way to have it invisible?

Thank you for your explanation and kind regards,

Werner

== 3 of 3 ==
Date: Mon, Nov 30 2009 9:55 am
From: James Kanze


On Nov 30, 11:58 am, werasm <wer...@gmail.com> wrote:

> 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

I don't think the fact that X is a template is relevant here. I
think you'll have the same problem with an ordinary class.

> {
> 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 );

A better message would be ``namespace "n" has no visible member
"foo"''. Namespace n clearly has a member foo, but it's not
been declared in a scope which would make it visible here.

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

Yep. When you say n::..., you're telling the compiler
explicitly to look at what is visible in n (which doesn't
necessarily contain everything that is in n). When you leave
the qualification off, you're telling the compiler to look at
what is normally visible at the call site, *and* at any
additional scopes introduced by ADL. In this case, ADL
introduces the scope of n::X, and in the scope of n::X, there is
a declaration which makes n::foo visible.

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

No bug, although probably not very intuitive. Just because
something exists in a given namespace doesn't mean that it is
visible in a given scope. A declaration must be visible in that
scope for it to be visible. A friend declaration isn't in the
surrounding namespace scope, but rather in the class, so it
only makes the symbol visible in the class scope. In your last
example, you have a declaration in the scope itself, so the
symbol becomes visible anytime lookup considers the scope.

--
James Kanze

==============================================================================
TOPIC: AutoFlowchart : auto generate flowchart from source code
http://groups.google.com/group/comp.lang.c++/t/5616ce70ade5faed?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Nov 30 2009 6:45 am
From: "fenglinyushu@163.com"


AutoFlowchart v2.4.6 is released!
-------------------------------------------------------------
AutoFlowchart is a excellent source code flowcharting tool to
generate
flowchart from source code. Its flowchart can expand and shrink. and
you can
pre-define the the width , height,Horizontal spacing and vertical
spacing.
Move and zoom is also very easy. It can export the flowchart as a
Microsoft
Visio,Word file or a bitmap file. It can help programmers understand,
document and visualize source code.
It supports C,C++,VC++(Visual C++ .NET),Delphi(Object Pascal).
Maybe it can help you!

What's New
-------------------------------------------------------------
1. update function to get function/procedure list;
2. add procession to "try" and "catch" statement;
3. fixed a bug when draw flowchart;

http://www.ezProg.com

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

== 1 of 3 ==
Date: Mon, Nov 30 2009 7:18 am
From: Juha Nieminen


aaragon wrote:
> However, there has to be a faster way to accomplish this

const char *startPtr = s.c_str(), *endpPtr;
double x = std::strtod(startPtr, &endPtr);
if(endPtr == startPtr) { /* error */ }

It's much faster because strtod (most probably) parses the string
in-place, unlike std::istringstream, which probably copies the string
for itself.


== 2 of 3 ==
Date: Mon, Nov 30 2009 7:43 am
From: aaragon


On Nov 30, 9:18 am, Juha Nieminen <nos...@thanks.invalid> wrote:
> aaragon wrote:
> > However, there has to be a faster way to accomplish this
>
>     const char *startPtr = s.c_str(), *endpPtr;
>     double x = std::strtod(startPtr, &endPtr);
>     if(endPtr == startPtr) { /* error */ }
>
>   It's much faster because strtod (most probably) parses the string
> in-place, unlike std::istringstream, which probably copies the string
> for itself.

Thank you for your answers. I tried lexical_cast, and it is actually
slower than the stream_cast function above. I will try the strtod.
Thanks again.


== 3 of 3 ==
Date: Mon, Nov 30 2009 7:41 am
From: "Johannes Schaub (litb)"


aaragon 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()?
>
strstream combines flexibility of c++ with the speed of strtod:

istrstream s(str.c_str());
double d; if(s >> d >> ws && ws.eof()) cout << "converted: " << d;

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

== 1 of 5 ==
Date: Mon, Nov 30 2009 7:21 am
From: Juha Nieminen


James Kanze wrote:
>> 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.

So you mean that you have to deliberately introduce a memory leak if
you want to make sure the container is not accessed after it has been
destroyed?

Is there *really* no better way of doing it?


== 2 of 5 ==
Date: Mon, Nov 30 2009 7:23 am
From: Juha Nieminen


James Kanze wrote:
> 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.

I would have never thought at a programming idiom requires deliberate
introduction of a memory leak into your program. Is it really the only way?


== 3 of 5 ==
Date: Mon, Nov 30 2009 8:13 am
From: "Balog Pal"


"Juha Nieminen" <nospam@thanks.invalid>
>> That's the usual singleton idiom.
>
> I would have never thought at a programming idiom requires deliberate
> introduction of a memory leak into your program. Is it really the only
> way?

Look up the Alexandrescu-singleton

== 4 of 5 ==
Date: Mon, Nov 30 2009 9:23 am
From: Vladimir Jovic


Juha Nieminen wrote:
> James Kanze wrote:
>>> 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.
>
> So you mean that you have to deliberately introduce a memory leak if
> you want to make sure the container is not accessed after it has been
> destroyed?
>
> Is there *really* no better way of doing it?

How about this:

class SharedContainer
{
public:
SharedContainer()
{
if ( 0 == Counter() )
{
c() = new Container;
}
++Counter();
}
~SharedContainer()
{
--Counter();
if ( 0 == Counter() )
{
delete c();
}
}

Container& GetContainer()
{
assert( NULL != c() );
return *c();
}

private:


Container *& c()
{
static Container *c = NULL;
return c;
}
int& Counter()
{
static int n = 0;
return n;
}
};

warning : I haven't tested this, but I am sure you got an idea ;)


--
ultrasound www.ezono.com


== 5 of 5 ==
Date: Mon, Nov 30 2009 10:05 am
From: James Kanze


On Nov 30, 3:21 pm, Juha Nieminen <nos...@thanks.invalid> wrote:
> James Kanze wrote:
> >> 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.

> So you mean that you have to deliberately introduce a memory
> leak if you want to make sure the container is not accessed
> after it has been destroyed?

How are you defining "memory leak". I don't see anything which
could be qualified as a memory leak, with any of the usual
definitions.

The only useful definition is "memory which leaks"; i.e. which
is periodically reallocated, with previous allocations going
unused, so that the program grows indefinitely. That's not the
case here. I have seen it defined as memory which can no longer
be accessed, because there are no more pointers to it; the only
use I can think of for this definition is to prove that you
can't get a memory leak with garbage collection. But the above
doesn't leak by this definition either, since there's always a
pointer to it.

> Is there *really* no better way of doing it?

It being? And "better" meaning?

If the goal is to ensure that an object is not destructed (which
is what you want here), then I don't know of any better way of
doing it than using an allocation without a delete.

--
James Kanze

==============================================================================
TOPIC: WWW.TOTRADEA.COM ★NO.1 Quality★ Wholesale Handbags, Edhardy,Gucci,
Chanel,LV,Juicy,UGG,Prada,Coach,D&G,Fendi handbags
http://groups.google.com/group/comp.lang.c++/t/c23dc88002d330d0?hl=en
==============================================================================

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


WWW.TOTRADEA.COM ★NO.1 Quality★ Wholesale Handbags,
Edhardy,Gucci,Chanel,LV,Juicy,UGG,Prada,Coach,D&G,Fendi handbags
"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"
"Welcome to our website www.toptradea.com ,if you are looking for the
top quality Iphone,Nokia,blackberry,htc,mobile phones, shoes and
clothes ,high quality, Quick shipment,Lowest price and Good service,
please contact with us.
Toptradeing Co.,Ltd was founded in 1995 and we are an actual
manufacturer and exporter of authentic brand Shoes
(Nike,jordan,Puma,adidas,dunk,shox,rift,....),Coat
(Juicy,Gucci,Gstar,CA,etc) t-shirt
(lacoste,polo,evisu,prada,bape),jeans( artful
dodger ,Evisu,bape,DG,Gucci,true religion,bbc jeans ,levus
jeans),handbags (gucci,lv,burberry,chanel,coach,Edhardy,dior) jackets
( Gucci,lv,rolex,bape,omega,Gucci,lv,rolex,bape),Suits
(juicy,Edhardy,Bape,etc),Dress
(Gucci,Armani,MiuMiu,Fendi,SF,Chloe,Yiand,Burberry,Lanvin,MJ,Karen
Millen,Maxmara,Sanshai,BCBG,Missoni,etc),Pants,Jersey
(NBA,NFL),hats,sunglasses
(Edhardy,Chanel,DG,Gucci,Dior,Coach,Armani,Prada,LV,Fedi,Catier,Ferri,Diesel,Burberry)
and strap,Wallets jewelry(Necklace, Chanel, Coach, D&G, Dior, Juicy,
Tiffany Necklace),etc

Currently, we can accept small orders. The more you order, the lower
the price will be. Based on our experience and successful performance
in the worldmarket ;Shoes market, we would like to tell you that we
are operating our own International Marketing Division with
experiences, so we can help our customers with many types of
shoes ,jeans,t-shirt,bags ,and othe products. we are confident that we
will be able to cooperate with your firm with high quality products at
competitive price.
For the price list and delivery time, would you please view our
website www toptradea com.And if any question, please do not hesitate
to contact with me.

Welcome to add my MSN.
Contact: selina
Phone: 86-593-2892302 Skype:toptradea
MSN: toptradea@hotmail.com
Email: toptradea@gmail.com
website: http://www.toptradea.com"

==============================================================================
TOPIC: ★→Iphone 3GS and 3G,Nokia N97,N96,Blackberry 9500,9000 fashion mobiles,
New,unlocked,one year warranty
http://groups.google.com/group/comp.lang.c++/t/7a66459a6e89a7d3?hl=en
==============================================================================

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


★→Iphone 3GS and 3G,Nokia N97,N96,Blackberry 9500,9000 fashion
mobiles, New,unlocked,one year warranty
"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 ]
"
"Welcome to our website www.toptradea.com ,if you are looking for the
top quality Iphone,Nokia,blackberry,htc,mobile phones, shoes and
clothes ,high quality, Quick shipment,Lowest price and Good service,
please contact with us.
Toptradeing Co.,Ltd was founded in 1995 and we are an actual
manufacturer and exporter of authentic brand Shoes
(Nike,jordan,Puma,adidas,dunk,shox,rift,....),Coat
(Juicy,Gucci,Gstar,CA,etc) t-shirt
(lacoste,polo,evisu,prada,bape),jeans( artful
dodger ,Evisu,bape,DG,Gucci,true religion,bbc jeans ,levus
jeans),handbags (gucci,lv,burberry,chanel,coach,Edhardy,dior) jackets
( Gucci,lv,rolex,bape,omega,Gucci,lv,rolex,bape),Suits
(juicy,Edhardy,Bape,etc),Dress
(Gucci,Armani,MiuMiu,Fendi,SF,Chloe,Yiand,Burberry,Lanvin,MJ,Karen
Millen,Maxmara,Sanshai,BCBG,Missoni,etc),Pants,Jersey
(NBA,NFL),hats,sunglasses
(Edhardy,Chanel,DG,Gucci,Dior,Coach,Armani,Prada,LV,Fedi,Catier,Ferri,Diesel,Burberry)
and strap,Wallets jewelry(Necklace, Chanel, Coach, D&G, Dior, Juicy,
Tiffany Necklace),etc

Currently, we can accept small orders. The more you order, the lower
the price will be. Based on our experience and successful performance
in the worldmarket ;Shoes market, we would like to tell you that we
are operating our own International Marketing Division with
experiences, so we can help our customers with many types of
shoes ,jeans,t-shirt,bags ,and othe products. we are confident that we
will be able to cooperate with your firm with high quality products at
competitive price.
For the price list and delivery time, would you please view our
website www toptradea com.And if any question, please do not hesitate
to contact with me.

Welcome to add my MSN.
Contact: selina
Phone: 86-593-2892302 Skype:toptradea
MSN: toptradea@hotmail.com
Email: toptradea@gmail.com
website: http://www.toptradea.com"

==============================================================================
TOPIC: =♡*★*♡=HOT SALE Nike,Jordan,Shox,Max,Dunk,Gucci,Supra,Edhardy,Lacoste,
Adidas,Prada,Doir,Lanvin,Hogan sneakers
http://groups.google.com/group/comp.lang.c++/t/a10d063258c67743?hl=en
==============================================================================

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


=♡*★*♡=HOT SALE
Nike,Jordan,Shox,Max,Dunk,Gucci,Supra,Edhardy,Lacoste,Adidas,Prada,Doir,Lanvin,Hogan
sneakers
"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 "
"Welcome to our website www.toptradea.com ,if you are looking for the
top quality Iphone,Nokia,blackberry,htc,mobile phones, shoes and
clothes ,high quality, Quick shipment,Lowest price and Good service,
please contact with us.
Toptradeing Co.,Ltd was founded in 1995 and we are an actual
manufacturer and exporter of authentic brand Shoes
(Nike,jordan,Puma,adidas,dunk,shox,rift,....),Coat
(Juicy,Gucci,Gstar,CA,etc) t-shirt
(lacoste,polo,evisu,prada,bape),jeans( artful
dodger ,Evisu,bape,DG,Gucci,true religion,bbc jeans ,levus
jeans),handbags (gucci,lv,burberry,chanel,coach,Edhardy,dior) jackets
( Gucci,lv,rolex,bape,omega,Gucci,lv,rolex,bape),Suits
(juicy,Edhardy,Bape,etc),Dress
(Gucci,Armani,MiuMiu,Fendi,SF,Chloe,Yiand,Burberry,Lanvin,MJ,Karen
Millen,Maxmara,Sanshai,BCBG,Missoni,etc),Pants,Jersey
(NBA,NFL),hats,sunglasses
(Edhardy,Chanel,DG,Gucci,Dior,Coach,Armani,Prada,LV,Fedi,Catier,Ferri,Diesel,Burberry)
and strap,Wallets jewelry(Necklace, Chanel, Coach, D&G, Dior, Juicy,
Tiffany Necklace),etc

Currently, we can accept small orders. The more you order, the lower
the price will be. Based on our experience and successful performance
in the worldmarket ;Shoes market, we would like to tell you that we
are operating our own International Marketing Division with
experiences, so we can help our customers with many types of
shoes ,jeans,t-shirt,bags ,and othe products. we are confident that we
will be able to cooperate with your firm with high quality products at
competitive price.
For the price list and delivery time, would you please view our
website www toptradea com.And if any question, please do not hesitate
to contact with me.

Welcome to add my MSN.
Contact: selina
Phone: 86-593-2892302 Skype:toptradea
MSN: toptradea@hotmail.com
Email: toptradea@gmail.com
website: http://www.toptradea.com"

==============================================================================
TOPIC: Looking for a good memory and CPU profiler
http://groups.google.com/group/comp.lang.c++/t/ac40d4006ea2c71c?hl=en
==============================================================================

== 1 of 2 ==
Date: Mon, Nov 30 2009 8:16 am
From: Johnson


Andy Champ wrote:
> Johnson wrote:
>> Thanks for the info, Ian. This project is developed under Microsoft
>> Visual C++ 2008. Do you have any recommendation for trhe profiler?
>> BTW, can you recommend me a few relevant forum?
>
> Microsoft Visual C++ 2008 has a profiler built in. Or at least, it did
> last week when I was profiling madly...
>
> Look for Analyze [sic] on the menus.
>
> Which edition do you have?
>
> Andy
Thank you, Andy, I am using Visual C++ 2008 Express Edition. Does it
have the tools you mentioned?

Johnson


== 2 of 2 ==
Date: Mon, Nov 30 2009 8:38 am
From: André Schreiter


Johnson schrieb:
> Andy Champ wrote:
> Thank you, Andy, I am using Visual C++ 2008 Express Edition. Does it
> have the tools you mentioned?

No, only Visual Studio Team System has it.

==============================================================================
TOPIC: Cheap Wholesale& Retail GHD discount GHD straightener (www.dotradenow.
com.cn)
http://groups.google.com/group/comp.lang.c++/t/8f0a7c92d1acebaa?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Nov 30 2009 9:01 am
From: yoyotrade


GHD MK4 MK5 cheap Wholesale, GHD hair straightener wholesale

Cheap Benefit GHD (www.dotradenow.com.cn)

Cheap Black GHD (www.dotradenow.com.cn)

Cheap Dark GHD (www.dotradenow.com.cn)

Cheap pink GHD (www.dotradenow.com.cn)

Cheap new style Leopard GHD (www.dotradenow.com.cn)

Cheap IV mini styler GHD (www.dotradenow.com.cn)

Cheap rare Leopard GHD (www.dotradenow.com.cn)

Cheap rare newest Leopard style (www.dotradenow.com.cn)

Cheap Gold GHD (www.dotradenow.com.cn)

Cheap Kiss GHD (www.dotradenow.com.cn)

Cheap pink MK5 (www.dotradenow.com.cn)

Cheap black GHD (www.dotradenow.com.cn)

Cheap limited edition MK5 (www.dotradenow.com.cn)

Cheap pure black GHD MK5 (www.dotradenow.com.cn)

Cheap pure white GHD (www.dotradenow.com.cn)

Cheap Pink style GHD (www.dotradenow.com.cn)

Cheap Purple style GHD with dryer (www.dotradenow.com.cn)

Cheap Salon GHD (www.dotradenow.com.cn)

CHI

Cheap Ammy green CHI (www.dotradenow.com.cn)

Cheap Black style CHI (www.dotradenow.com.cn)

Cheap Blue style CHI (www.dotradenow.com.cn)

Cheap Camouflage Blue CHI (www.dotradenow.com.cn)

Cheap Camouflage pink CHI (www.dotradenow.com.cn)

Cheap Peachblow CHI (www.dotradenow.com.cn)

Cheap Pink style CHI (www.dotradenow.com.cn)

Cheap Red-black CHI (www.dotradenow.com.cn)

Cheap Wide red-black CHI(www.dotradenow.com.cn)

Cheap crimping iron (www.dotradenow.com.cn)

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

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


On Nov 30, 10:11 am, Nick Keighley <nick_keighley_nos...@hotmail.com>
wrote:
> 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).

Certainly. RAII doesn't apply to entity objects (which means
most dynamically allocated memory). On the other hand, it's
very useful, for enforcing transactional semantics within the
transaction which handles the events: it probably applies to 95%
or more semaphore locks, for example.

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

It's true, and the secret to quality programming is to not add
bugs. That's why people use code review and unit tests and any
number of other techniques (like not writing overly complicated
code to begin with).

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

It's a stupid rule anyway. It doesn't work in practice. The
real rule for memory management is not to use dynamic allocation
at all, except when the object lifetime is explicit (e.g. a call
in a telephone system). And of course then, your design (or
more directly, your requirements specification) determines when
the object should be deleted.

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

That's probably not a good example. The text buffer holds the
text before it's deleted, and the deleted text itself is never a
separate object, unless...

> What if the editor has Undo/Redo?

Then you save the deleted text in a redo record. Which will be
deleted when the requirements specifications says it should be
deleted.

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

Which comes down to the same. Sometimes the factory method is
justified---it may be preferable to check pre-conditions
beforehand, or to register the created object with a transaction
(so it can be correctly deleted in case of rollback).

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

It it is the correct time, then you don't want dynamic
allocation to begin with.

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

I'm not sure what CallAP is, but this looks like a familiar
pattern (except that I'd probably keep the newly created call
object in an auto_ptr until I'd successfully returned from
CallList::add_call). And of course, if the event is "hang up",
and that brings the connection count in the call down to zero,
it is the call itself (in a function called from
Call::process_event) which will do the delete.

--
James Kanze

==============================================================================
TOPIC: how to achieve low latency in C++
http://groups.google.com/group/comp.lang.c++/t/a27acf7c042642e9?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Nov 30 2009 10:50 am
From: Maxim Yegorushkin


bubai wrote:

> Currently I am involved in developing a trading system. The server
> side is written in C++ the agenda here is that the system has to be a
> low latent system.

There are a few fundamental principles you should follow. Your server will
exhibit low latency to the extent you adhere to these principles:

1) Avoid data copying. Prefer zero-copy algorithms. For example, when you
send/receive data through a socket use a ring-buffer with wrapping iterators.
2) Avoid dynamic memory allocation on fast code paths, such as receiving market
data and sending orders. Preallocate as much as possible. Use mapped memory.
3) Avoid lock contention. Use wait-free and lock-free algorithms if possible,
share as little data as possible between threads.
4) Avoid context switching. Don't have more threads ready to run than hardware
CPUs. Use fifo realtime process priority, so that your threads do not get
context switched off when it still has data to process.

One of the top latency killers is formatting strings using things like
std::stringstream or snprintf into std::string. This is because they do a fancy
data copy (1), dynamic memory allocation (2), locking a mutex (3) when doing the
memory allocation (unless some fancy multi-thread allocator is used that avoid
locking a mutex).

> Is there any book or reference or white papers
> which tell us what are the techniques to write low latency code in C+
> +.... Any help will be highly appreciated.

Start with http://www.kegel.com/c10k.html

--
Max

==============================================================================
TOPIC: What is fastest?
http://groups.google.com/group/comp.lang.c++/t/917a17e130cd2dc9?hl=en
==============================================================================

== 1 of 1 ==
Date: Mon, Nov 30 2009 11:02 am
From: "carl"


What is fastest, indexing or iterating a std::vector:


std::vector<std::string> container;
// Add 100000 strings to container

std::vector<std::string>::iterator it = container.begin()
while (it != container.end()) {
std::string str = *it;
// do something with str
it++;
}


or

int size = container.size();
for (int i=0; i< size; i++) {
std::string str = container[i];
// do something with str
}

On this page:

http://stackoverflow.com/questions/776624/whats-faster-iterating-an-stl-vector-with-vectoriterator-or-with-at


there are some different opinions, but what are your experinces?

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

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

Re: [jQuery] Jquery specialist for hire

There was a pretty good example posted here a few days ago that may have all the code you need:

http://groups.google.com/group/jquery-en/msg/546500f34de23d79

The problem that Darjana was asking about shouldn't apply in your case; just be sure to use the full absolute URL to your Server 2.

You'll need to fill in the specifics, but you can see where the jQuery code sends some data up to the server, the PHP code on the server reads that data and sends back a JSON response (actually JSONP - that's how you work around the cross-domain issue), and the jQuery code reads that data that the server sent.

-Mike

On Mon, Nov 30, 2009 at 8:40 AM, Bjorn Symister <bjorn.oso@gmail.com> wrote:
I have posted on craigslist with no luck, so I will post here.  I am seeking a specific jQuery solution.  Please name your rate and I can pay through paypal.  I needed this solution last week :)

My Scenario, 2 Servers, 2 Scripts, 1 Form.
Form collects Email addresses.  This form is on Server 1: my client end server.  I can only place html,javascript,css on this server.  No server side scripts.

On Server 2: I will have a php script that will receive the data or use jQuery getJSON to get it..  

Problem: I need to handle the submission of the data without refreshing the entire page (need Ajax).  Problem is however using Ajax, you cannot send data to another domain (So I've read).  Options are using an iFrame or JSON.  I would prefer JSON, however at this point, I just need a solution.  If you know how to do this, please just name your fixed rate to provide the scripts and I'll take it from there.

Thanks,

Bjorn

[jQuery] slideToggle Functions

I have a simple bit of jQuery that I just can't get working.

$('#my-element').click(function(){
$('#list-element').slideToggle(function(){
$('#status-element').html('show artist index');
console.log('show');
},function(){
$('#status-element').html('hide artist index');
console.log('hide');
}
);
});

Right? Simple? I've had it working before, but whenever the element is
clicked, the element toggles but the console prints 'hide' every time
and the #status-element never gets changed. I have also tried just
using toggle() instead of slideToggle and also

slideToggle(200,function(){...

(including the speed before the callback functions).

Any ideas would be appreciated!

Thanks,
Gavin

Re: [jQuery] Re: Problem with plugins

Could it be that you are also loading prototype.js or some other library that redefines the $() function?

Does it find plugin methods if you use jQuery(...)... instead of $(...)...?

Do the built-in jQuery methods show up?

What does it display if you enter each of these lines into the Firebug console:

$().jquery

jQuery().jquery

Sooner or later you may have to post that test page. Sooner would be better, save us all a lot of work. :-)

-Mike

On Mon, Nov 30, 2009 at 7:48 AM, Paulodemoc <paulodemoc@gmail.com> wrote:
The plugins are being loaded. When I open the source code and click on
the js url, it opens alright....
But when I call the command:

$(selector).pluginFunction({options});

An error message appears saying that pluginFunction is not a
function... on ALL plugins...

On Nov 27, 12:45 pm, Brett Ritter <swift...@swiftone.org> wrote:
> On Mon, Nov 23, 2009 at 5:55 AM,Paulodemoc<paulode...@gmail.com> wrote:
> > Its the javasscript on the php page, and the only php there is to
> > output the urls, and these urls are being printed correctly....
> > The url doesn't affect the understanding of the rest of the code...
>
> If your plugins aren't loading, those URLs are quite likely involved.
> We have no way of knowing if they are indeed working since we don't
> see the output.
>
> Try sending the HTML the browser is getting.
>
> --
> Brett Ritter / SwiftOne
> swift...@swiftone.org

[jQuery] Jquery specialist for hire

I have posted on craigslist with no luck, so I will post here.  I am seeking a specific jQuery solution.  Please name your rate and I can pay through paypal.  I needed this solution last week :)

My Scenario, 2 Servers, 2 Scripts, 1 Form.
Form collects Email addresses.  This form is on Server 1: my client end server.  I can only place html,javascript,css on this server.  No server side scripts.

On Server 2: I will have a php script that will receive the data or use jQuery getJSON to get it..  

Problem: I need to handle the submission of the data without refreshing the entire page (need Ajax).  Problem is however using Ajax, you cannot send data to another domain (So I’ve read).  Options are using an iFrame or JSON.  I would prefer JSON, however at this point, I just need a solution.  If you know how to do this, please just name your fixed rate to provide the scripts and I’ll take it from there.

Thanks,

Bjorn

[jQuery] Superfish How-to?

Hi,
I would like to try superfish in a joomla template.
I am new to this list. I need somebody to guide me through the
procedures to get it working.
a. Where do you create or copy files to in the site structure, root or
template folder?
b. When using hoverIntent, where do those files go?
c. What changes are necessary in the index.php file?
d. Which CSS files affect the styling and operation of superfish
plugin?
e. Is it necessary to install anything via the administrator backend.

I have been using joomla for about a year, I am comfortable working
with CSS and html.

Sincerely,

Jeff

[jQuery] Re: Having trouble getting Superfish to work...

Hi,
I would like to try superfish in a joomla template.
I am new to this list. I need somebody to guide me through the
procedures to get it working.
a. Where do you create or copy files to in the site structure, root or
template folder?
b. When using hoverIntent, where do those files go?
c. What changes are necessary in the index.php file?
d. Which CSS files affect the styling and operation of superfish
plugin?
e. Is it necessary to install anything via the administrator backend.

I have been using joomla for about a year, I am comfortable working
with CSS and html.

Sincerely,

Jeff

[jQuery] Re: Problem with plugins

On Nov 30, 10:48 am, Paulodemoc <paulode...@gmail.com> wrote:
> The plugins are being loaded. When I open the source code and click on
> the js url, it opens alright....
> But when I call the command:
>
> $(selector).pluginFunction({options});
>
> An error message appears saying that pluginFunction is not a
> function... on ALL plugins...

As others have said, this seems to mean that the plug-in scripts are
not referenced properly. Is there a way you can strip down your
output and post it, perhaps on JSBin?

-- Scott

Re: [jQuery] Re: Hide chat content

Ya, here is my problem. I know how to make the ajax call, and it all works, but, I need to somehow connect the msg id from the mysql database to the ajax call, so I need another div, that has the id.

[jQuery] Re: Problem with plugins

The plugins are being loaded. When I open the source code and click on
the js url, it opens alright....
But when I call the command:

$(selector).pluginFunction({options});

An error message appears saying that pluginFunction is not a
function... on ALL plugins...

On Nov 27, 12:45 pm, Brett Ritter <swift...@swiftone.org> wrote:
> On Mon, Nov 23, 2009 at 5:55 AM,Paulodemoc<paulode...@gmail.com> wrote:
> > Its the javasscript on the php page, and the only php there is to
> > output the urls, and these urls are being printed correctly....
> > The url doesn't affect the understanding of the rest of the code...
>
> If your plugins aren't loading, those URLs are quite likely involved.
> We have no way of knowing if they are indeed working since we don't
> see the output.
>
> Try sending the HTML the browser is getting.
>
> --
> Brett Ritter / SwiftOne
> swift...@swiftone.org

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