comp.lang.c++
http://groups.google.com/group/comp.lang.c++?hl=encomp.lang.c++@googlegroups.com
Today's topics:
* addr to long - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/8c07d55c00e3053e?hl=en
* Delegates ,smart pointers and GUI - 6 messages, 4 authors
http://groups.google.com/group/comp.lang.c++/t/f5ef7b3e0a822708?hl=en
* std::abs ambiguity - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/ecfa9110b83039de?hl=en
* Window C++ Compiler - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/c70a2463dd900f3e?hl=en
* STL map+vector compilation failure issue - 6 messages, 5 authors
http://groups.google.com/group/comp.lang.c++/t/492e3b6157308868?hl=en
* ostream::write - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/a8929aac2301abf6?hl=en
* function implementation with stack vs heap allocation - 4 messages, 3
authors
http://groups.google.com/group/comp.lang.c++/t/05f7537165e6c5f4?hl=en
* >>>>Just Do It<<<<< NIKE sneakers wholesale free shipping paypal payment - 1
messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/d54356e70fec3396?hl=en
* Implicit conversion and method call - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/1af613b157b9cd86?hl=en
* contiguous in memory - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/a5e84c1f1717e18c?hl=en
==============================================================================
TOPIC: addr to long
http://groups.google.com/group/comp.lang.c++/t/8c07d55c00e3053e?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Apr 30 2009 4:05 am
From: Juha Nieminen
Krzysztof Poc wrote:
> Hello
>
> How can I convert ptr (of any type) to long.
> Can I do that as follows:
>
> long addr = reinterpret_cast<long>(&objOfAnyType);
>
> Is it correct for all platforms 32/64 bit ?
The standard does not guarantee that sizeof(long) equals sizeof(void*)
(and in fact, in MSVC long is 32-bit and void* is 64-bit when compiling
a 64-bit binary).
If you want a signed integral which is as large as a pointer, use the
ptrdiff_t standard type. (If you want it unsigned, use size_t.)
==============================================================================
TOPIC: Delegates ,smart pointers and GUI
http://groups.google.com/group/comp.lang.c++/t/f5ef7b3e0a822708?hl=en
==============================================================================
== 1 of 6 ==
Date: Thurs, Apr 30 2009 4:53 am
From: KjellKod
Something very similar as 'delegates' are in fact commonly used in C++
(GUI) frameworks.
Check out signals by
Boost (http://www.boost.org/doc/libs/1_38_0/doc/html/signals.html)
and Qt (http://doc.trolltech.com/4.5/signalsandslots.html)
Other not so famous examples but still open source examples of signals
are also available
(KSignals http://kjell.hedstrom.googlepages.com/signalandslots and
SigSlot http://sigslot.sourceforge.net/)
Using signals you have type safe function callback (i.e. similar to
delegate) encapsuled
in signals (and slots) making it easy to use for anyone without
requiring too much information
about how they work in detail.
== 2 of 6 ==
Date: Thurs, Apr 30 2009 6:16 am
From: Phlip
KjellKod wrote:
> Something very similar as 'delegates' are in fact commonly used in C++
> (GUI) frameworks.
> Check out signals by
> Boost (http://www.boost.org/doc/libs/1_38_0/doc/html/signals.html)
> and Qt (http://doc.trolltech.com/4.5/signalsandslots.html)
Signals and slots are not "in C++". Trolltech provides them by adding two new
keywords to C++. You can't do what they did without their language extension.
Oh, and the keywords provide dynamic typing and a kind of closure. Go figure!
--
Phlip
== 3 of 6 ==
Date: Thurs, Apr 30 2009 7:07 am
From: SG
On 30 Apr., 15:16, Phlip <phlip2...@gmail.com> wrote:
> KjellKod wrote:
> > Something very similar as 'delegates' are in fact commonly used in C++
> > (GUI) frameworks.
> > Check out signals by
> > Boost (http://www.boost.org/doc/libs/1_38_0/doc/html/signals.html)
> > and Qt (http://doc.trolltech.com/4.5/signalsandslots.html)
>
> Signals and slots are not "in C++". Trolltech provides them by adding two new
> keywords to C++. You can't do what they did without their language extension.
It's my understanding that a similar feature can be more or less
emulated with C++ language features. IIRC, Trolltech didn't do it that
way because they started development early and C++ compilers were not
very mature w.r.t. templates back then.
I'm not much of a GUI programmer but I did check out gtkmm a little
bit. They also have signals and slots but they're implemented as a C++
library.
The only experience with GUI programming I have is with Java/Swing.
The talk about closures reminded of the need to write something like
SwingUtilities.invokeLater(new Runnable(){
public void run() {
// do something
}
});
in Java if you're in another thread and want an action to be performed
in Swing's event loop thread. In C++0x you'd be able to do something
similar:
// called from event loop thread as result of
// a user action, for example
void foo::on_click() {
MyGuiFramework::perform_async(
[] { calculations(); }, // async job
[this] { this->ready(); } // when done
);
}
// called from event loop thread
// (after calculations are complete)
void foo::ready() {
// ...
}
where most of the magic is hidden behind the fictional
"MyGuiFramework::perform_async". This is just one idea that comes to
mind. ;-)
Cheers!
SG
== 4 of 6 ==
Date: Thurs, Apr 30 2009 8:03 am
From: boltar2003@yahoo.co.uk
On Thu, 30 Apr 2009 07:07:37 -0700 (PDT)
SG <s.gesemann@gmail.com> wrote:
>in Java if you're in another thread and want an action to be performed
>in Swing's event loop thread. In C++0x you'd be able to do something
>similar:
I don't understand why you'd want threading built into the core C++ language.
Threads are an OS facility with many different attributes across many
different systems. Is the language going to support every single one of
these including low level tweaking or will it just have a common subset
making it useless for anyone who needs something a bit more specialised?
And if its going to support threading natively as opposed to being in
a system library why stop at threads - why not add multiprocess while
they're at it? Perhaps finally Windows could finally get a half decent
implementation of fork()!
B2003
== 5 of 6 ==
Date: Thurs, Apr 30 2009 8:17 am
From: SG
On 30 Apr., 17:03, boltar2...@yahoo.co.uk wrote:
> On Thu, 30 Apr 2009 07:07:37 -0700 (PDT)
>
> SG <s.gesem...@gmail.com> wrote:
> >in Java if you're in another thread and want an action to be performed
> >in Swing's event loop thread. In C++0x you'd be able to do something
> >similar:
>
> I don't understand why you'd want threading built into the core C++ language.
I suggested nothing of that kind. MyGuiFramework::perform_async is a
fictional function that just "magically" works. So, it *could* use
some form of OS specific threading library.
If you're working with some GUI framework (typical event loop thingy)
and want to stay responsive while loading a file or computing
something, you *have* to use threads. I'm sure that most of the GUI
toolkits that are available for C++ come with some sort of threading
support and synchronization primitives just for that reason.
By the way, C++0x will support threading directly.
Cheers!
SG
== 6 of 6 ==
Date: Thurs, Apr 30 2009 8:52 am
From: boltar2003@yahoo.co.uk
On Thu, 30 Apr 2009 08:17:20 -0700 (PDT)
SG <s.gesemann@gmail.com> wrote:
>By the way, C++0x will support threading directly.
Thats what I was talking about.
B2003
==============================================================================
TOPIC: std::abs ambiguity
http://groups.google.com/group/comp.lang.c++/t/ecfa9110b83039de?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Apr 30 2009 5:19 am
From: "Christopher Dearlove"
"Alf P. Steinbach" <alfps@start.no> wrote in message
news:gtbrpn$1rt$1@news.eternal-september.org...
> You're talking about an implementation conforming to C++98?
I was talking about de facto C++98 and de jure C++0X according to James's
third model.
> Assuming that works nicely, and I can't see why not, it isn't difficult.
> As is oft stated, the solution to every computer science problem is
> indirection. :-)
There's enough detail there for me to see how to do it. Why anyone
would want to do it (as you are deliberately setting out to follow that
model rather than the other two) is less clear, though I suppose it may
relate to being able to compile more C programs written not aware of
C++ with a C++ compiler (those using abs in various ways for example).
Thanks.
==============================================================================
TOPIC: Window C++ Compiler
http://groups.google.com/group/comp.lang.c++/t/c70a2463dd900f3e?hl=en
==============================================================================
== 1 of 2 ==
Date: Thurs, Apr 30 2009 5:50 am
From: Lionel B
On Thu, 30 Apr 2009 04:03:19 -0700, James Kanze wrote:
> On Apr 29, 5:43 pm, Noah Roberts <n...@nowhere.com> wrote:
>> red floyd wrote:
>> > cplusplusquest...@gmail.com wrote:
>> >> I'm using Linux C++ compiler. Is there anyone recommend me which
>> >> free Window C++ compiler is good? Thanks!
>
>> > G++ has a Windows port as well. Google for MinGW. If you'd prefer a
>> > full Linux style environment, google for Cygwin.
>
> Which you can also use with VC++.
>
>> You don't need Cygwin to get the Linux unix shell and tools. The people
>> who make MinGW also make Msys. You only need Cygwin if you need unix
>> compatibility.
>
> Unix compatibility in what way. My experience with this is that Cygwin
> and MSys don't integrate very well with Windows; it's like having two
> different systems, in different windows, and it's very awkward to use
> anything but the Cygwin/MSys tools from one of their shells.
Agreed. But is it fair to expect Cygwin to be "compatible" in the sense
of integrating seamlessly with Windows? Ultimately Windows != Unix and
perhaps the best we should expect of Cygwin is as a (partially) self-
contained Linux-alike environment running under the Windows OS with an
interface - albeit somewhat clunky - to Windows resources. Perhaps it
could be done better...
[In a former job I did once find Cygwin something of a life-saver. Coming
from a Unix background I became increasingly aware and frustrated at how
much easier it would be to get the work done productively in a Unix
environment. I managed to get away with installing Cygwin under the (very
MS-entrenched) sysadmin's radar and, on the whole, it delivered - albeit
not quite seamlessly.]
> MSys is
> the worst here, since it doesn't allow passing command line arguments
> beginning with / to the program you're invoking (and not all Windows
> programs are as open as VC++, and accept - to indicate an option, rather
> than /); output from the MSys tools also uses the Unix line separator,
> which can cause problems with some Windows tools. (And of course, if you
> don't need any of the native Windows tools, you can just install Linux,
> and get even better integration of the Unix toolkit).
Sure - but I don't believe MSYS purports to be much more than a minimal
implementation of a minimal environment enabling a minimal GNU/GCC
development toolchain. I agree that it is, even in this respect, flawed.
[...]
--
Lionel B
== 2 of 2 ==
Date: Thurs, Apr 30 2009 6:41 am
From: red floyd
James Kanze wrote:
> On Apr 29, 5:43 pm, Noah Roberts <n...@nowhere.com> wrote:
>> red floyd wrote:
>>> cplusplusquest...@gmail.com wrote:
>>>> I'm using Linux C++ compiler. Is there anyone recommend me which free
>>>> Window C++ compiler is good? Thanks!
>
>>> G++ has a Windows port as well. Google for MinGW. If you'd
>>> prefer a full Linux style environment, google for Cygwin.
>
> Which you can also use with VC++.
>
I mentioned it because OP had specified he was using Linux already.
==============================================================================
TOPIC: STL map+vector compilation failure issue
http://groups.google.com/group/comp.lang.c++/t/492e3b6157308868?hl=en
==============================================================================
== 1 of 6 ==
Date: Thurs, Apr 30 2009 6:02 am
From: boltar2003@yahoo.co.uk
Hi
I'm probably making some idiot mistake but can someone tell me why the
following fails to compile with a no matching function call error under
gcc:
map<int,vector<pair<int,int> > > m;
m[123] = vector<pair<int,int> >(pair<int,int>(2,3));
However a simple integer vector in the map compiles just fine:
map<int,vector<int> > m2;
m2[123] = vector<int>(2);
I can easily work around the issue but I'd like to know what I'm doing
wrong anyway. Thanks for any help
B2003
== 2 of 6 ==
Date: Thurs, Apr 30 2009 6:13 am
From: "Thomas J. Gritzan"
boltar2003@yahoo.co.uk schrieb:
> Hi
>
> I'm probably making some idiot mistake but can someone tell me why the
> following fails to compile with a no matching function call error under
> gcc:
>
> map<int,vector<pair<int,int> > > m;
> m[123] = vector<pair<int,int> >(pair<int,int>(2,3));
Because there's no constructor in vector that takes a pair?
Try this:
m[123] = vector<pair<int,int> >( 42, make_pair(2,3) );
This constructs a vector with 42 elements, each copy constructed from a
pair<int,int>.
The make_pair function allows to omit the template parameters of the pair.
--
Thomas
== 3 of 6 ==
Date: Thurs, Apr 30 2009 6:17 am
From: boltar2003@yahoo.co.uk
On Thu, 30 Apr 2009 15:13:28 +0200
"Thomas J. Gritzan" <phygon_antispam@gmx.de> wrote:
>
>
>boltar2003@yahoo.co.uk schrieb:
>> Hi
>>
>> I'm probably making some idiot mistake but can someone tell me why the
>> following fails to compile with a no matching function call error under
>> gcc:
>>
>> map<int,vector<pair<int,int> > > m;
>> m[123] = vector<pair<int,int> >(pair<int,int>(2,3));
>
>Because there's no constructor in vector that takes a pair?
But why would it need a specific pair constructor anyway? Why doesn't it just
use the generic templated constructor?
B2003
== 4 of 6 ==
Date: Thurs, Apr 30 2009 6:45 am
From: red floyd
boltar2003@yahoo.co.uk wrote:
> Hi
>
> I'm probably making some idiot mistake but can someone tell me why the
> following fails to compile with a no matching function call error under
> gcc:
>
> map<int,vector<pair<int,int> > > m;
> m[123] = vector<pair<int,int> >(pair<int,int>(2,3));
>
> However a simple integer vector in the map compiles just fine:
>
> map<int,vector<int> > m2;
> m2[123] = vector<int>(2);
>
Because the int parameter to the vector constructor is not a member, but
a *COUNT*.
m2[123] = vector<int>(2);
Creates a vector with 2 default constructed ints.
Try reading the documentation on vector.
== 5 of 6 ==
Date: Thurs, Apr 30 2009 6:46 am
From: Vaclav Haisman
boltar2003@yahoo.co.uk wrote, On 30.4.2009 15:17:
> On Thu, 30 Apr 2009 15:13:28 +0200
> "Thomas J. Gritzan" <phygon_antispam@gmx.de> wrote:
>>
>> boltar2003@yahoo.co.uk schrieb:
>>> Hi
>>>
>>> I'm probably making some idiot mistake but can someone tell me why the
>>> following fails to compile with a no matching function call error under
>>> gcc:
>>>
>>> map<int,vector<pair<int,int> > > m;
>>> m[123] = vector<pair<int,int> >(pair<int,int>(2,3));
>> Because there's no constructor in vector that takes a pair?
>
> But why would it need a specific pair constructor anyway? Why doesn't it just
> use the generic templated constructor?
std::vector has several ctors but none that would take value of type T. See
e.g. <http://stdcxx.apache.org/doc/stdlibref/vector.html#idx1305>.
--
VH
== 6 of 6 ==
Date: Thurs, Apr 30 2009 7:01 am
From: Pete Becker
boltar2003@yahoo.co.uk wrote:
> On Thu, 30 Apr 2009 15:13:28 +0200
> "Thomas J. Gritzan" <phygon_antispam@gmx.de> wrote:
>>
>> boltar2003@yahoo.co.uk schrieb:
>>> Hi
>>>
>>> I'm probably making some idiot mistake but can someone tell me why the
>>> following fails to compile with a no matching function call error under
>>> gcc:
>>>
>>> map<int,vector<pair<int,int> > > m;
>>> m[123] = vector<pair<int,int> >(pair<int,int>(2,3));
>> Because there's no constructor in vector that takes a pair?
>
> But why would it need a specific pair constructor anyway? Why doesn't it just
> use the generic templated constructor?
>
Which generic templated constructor do you want it to use? Hint: don't
guess; look at the specification for vector.
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of
"The Standard C++ Library Extensions: a Tutorial and Reference"
(www.petebecker.com/tr1book)
==============================================================================
TOPIC: ostream::write
http://groups.google.com/group/comp.lang.c++/t/a8929aac2301abf6?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Apr 30 2009 6:43 am
From: Vaclav Haisman
Ralf Goertz wrote, On 30.4.2009 11:12:
> Hi,
>
> what is the reason that
>
> ostream& ostream::write ( const char* s , streamsize n );
>
> is not defined as
>
> ostream& ostream::write ( const void* p , streamsize n );
>
> like its C-counterpart?
I suspect two reasons: 1st, char is what streams are about, and 2nd, aliasing
issues. Maybe even 3rd, type safety. The former forces you to stop and think
and add the cast to char* while the latter accepts any pointer.
--
VH
==============================================================================
TOPIC: function implementation with stack vs heap allocation
http://groups.google.com/group/comp.lang.c++/t/05f7537165e6c5f4?hl=en
==============================================================================
== 1 of 4 ==
Date: Thurs, Apr 30 2009 7:21 am
From: "Hicham Mouline"
Hello,
I have a function f that is called a large number of times
my current implementation is
bool f( iterator begin, iterator end ... )
{
const size_t n =end - begin;
....
....
boost::scoped_array<some_type> a( new some_type[n] );
...
...
return true;
}
However I tested the same implementation with a on-stack allocation
bool f( iterator begin, iterator end ... )
{
const size_t n =end - begin;
....
....
const size_t maxN = 64;
if (n>64)
{
return false;
}
some_type a[maxN ]; // or maybe boost::array< some_type, maxN > a;
...
...
return true;
}
Given the size of my problem, I am mostly in implementation 2, but sometimes
it may be over 64 and therefore would like to use dynamic allocation.
How can I not duplicate the code ? I can't see it.
some_type* a;
if (n>64){
a = new ...
}
else{
a = ???
}
regards,
is this the kind of things STL allocators do? should I template this
function with an allocator?
== 2 of 4 ==
Date: Thurs, Apr 30 2009 8:02 am
From: SG
On 30 Apr., 16:21, "Hicham Mouline" <hic...@mouline.org> wrote:
> Hello,
>
> I have a function f that is called a large number of times
> my current implementation is
>
> bool f( iterator begin, iterator end ... )
> {
> const size_t n =end - begin;
> ....
> ....
> boost::scoped_array<some_type> a( new some_type[n] );
> ...
> ...
> return true;
> }
>
> However I tested the same implementation with a on-stack allocation
> [...]
> Given the size of my problem, I am mostly in implementation 2, but sometimes
> it may be over 64 and therefore would like to use dynamic allocation.
>
> How can I not duplicate the code ? I can't see it.
The simple solution would be to separate allocation and the "real
work":
bool backend(iterator begin, iterator end, some_type* p, ..... )
{
// real work with p
}
bool f(iterator begin, iterator end, ..... )
{
const size_t n =end - begin;
if (n<=64) {
some_type arr[64];
return backend(begin,end,arr, ..... );
} else {
vector<some_type> vec (n);
return backend(begin,end,&vec[0], ..... );
}
}
Cheers!
SG
== 3 of 4 ==
Date: Thurs, Apr 30 2009 8:17 am
From: "Hicham Mouline"
"SG" <s.gesemann@gmail.com> wrote in message
news:bf579ef7-eb1e-4878-9683-69ea71c43680@q33g2000pra.googlegroups.com...
On 30 Apr., 16:21, "Hicham Mouline" <hic...@mouline.org> wrote:
> Hello,
>
> I have a function f that is called a large number of times
> my current implementation is
>
> bool f( iterator begin, iterator end ... )
> {
> const size_t n =end - begin;
> ....
> ....
> boost::scoped_array<some_type> a( new some_type[n] );
> ...
> ...
> return true;
> }
>
> However I tested the same implementation with a on-stack allocation
> [...]
> Given the size of my problem, I am mostly in implementation 2, but
> sometimes
> it may be over 64 and therefore would like to use dynamic allocation.
>
> How can I not duplicate the code ? I can't see it.
The simple solution would be to separate allocation and the "real
work":
bool backend(iterator begin, iterator end, some_type* p, ..... )
{
// real work with p
}
bool f(iterator begin, iterator end, ..... )
{
const size_t n =end - begin;
if (n<=64) {
some_type arr[64];
return backend(begin,end,arr, ..... );
} else {
vector<some_type> vec (n);
return backend(begin,end,&vec[0], ..... );
}
}
Cheers!
SG
-------------------
I'd need to make backend inline...
otherwise I may lose the benefit gained from having the array on the stack,
no?
== 4 of 4 ==
Date: Thurs, Apr 30 2009 8:59 am
From: pjb@informatimago.com (Pascal J. Bourguignon)
"Hicham Mouline" <hicham@mouline.org> writes:
> The simple solution would be to separate allocation and the "real
> work":
>
> bool backend(iterator begin, iterator end, some_type* p, ..... )
> {
> // real work with p
> }
>
> bool f(iterator begin, iterator end, ..... )
> {
> const size_t n =end - begin;
> if (n<=64) {
> some_type arr[64];
> return backend(begin,end,arr, ..... );
> } else {
> vector<some_type> vec (n);
> return backend(begin,end,&vec[0], ..... );
> }
> }
>
> Cheers!
> SG
> -------------------
> I'd need to make backend inline...
> otherwise I may lose the benefit gained from having the array on the stack,
> no?
Compile this function to assembler and see what it does. Short
answer: No, you won't lose anything. More, if you use a recent gcc,
you may get TCO so the return backend() is actually implemented with a
JMP instead of JSR/RET.
--
__Pascal Bourguignon__
==============================================================================
TOPIC: >>>>Just Do It<<<<< NIKE sneakers wholesale free shipping paypal
payment
http://groups.google.com/group/comp.lang.c++/t/d54356e70fec3396?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Apr 30 2009 7:44 am
From: wholesale free shipping
Discount Nike air jordans (www.guoshitrade.com)
Discount Nike Air Max 90 Sneakers (www.guoshitrade.com)
Discount Nike Air Max 91 Supplier (www.guoshitrade.com)
Discount Nike Air Max 95 Shoes Supplier (www.guoshitrade.com)
Discount Nike Air Max 97 Trainers (www.guoshitrade.com)
Discount Nike Air Max 2003 Wholesale (www.guoshitrade.com)
Discount Nike Air Max 2004 Shoes Wholesale (www.guoshitrade.com)
Discount Nike Air Max 2005 Shop (www.guoshitrade.com)
Discount Nike Air Max 2006 Shoes Shop (www.guoshitrade.com)
Discount Nike Air Max 360 Catalogs (www.guoshitrade.com)
Discount Nike Air Max Ltd Shoes Catalogs (www.guoshitrade.com)
Discount Nike Air Max Tn Men's Shoes (www.guoshitrade.com)
Discount Nike Air Max Tn 2 Women's Shoes (www.guoshitrade.com)
Discount Nike Air Max Tn 3 Customize (www.guoshitrade.com)
Discount Nike Air Max Tn 4 Shoes Customize ( www.guoshitrade.com)
Discount Nike Air Max Tn 6 Supply (www.guoshitrade.com)
Discount Nike Shox NZ Shoes Supply (www.guoshitrade.com)
Discount Nike Shox OZ Sale (www.guoshitrade.com)
Discount Nike Shox TL Store (www.guoshitrade.com)
Discount Nike Shox TL 2 Shoes Store (www.guoshitrade.com)
Discount Nike Shox TL 3 Distributor (www.guoshitrade.com)
Discount Nike Shox Bmw Shoes Distributor (www.guoshitrade.com)
Discount Nike Shox Elite Shoes Manufacturer (www.guoshitrade.com)
Discount Nike Shox Monster Manufacturer (www.guoshitrade.com)
Discount Nike Shox R4 Running Shoes (www.guoshitrade.com)
Discount Nike Shox R5 Mens Shoes (www.guoshitrade.com)
Discount Nike Shox Ride Womens Shoes (www.guoshitrade.com)
Discount Nike Shox Rival Shoes Wholesaler (www.guoshitrade.com)
Discount Nike Shox Energia Wholesaler (www.guoshitrade.com)
Discount Nike Shox LV Sneaker (www.guoshitrade.com)
Discount Nike Shox Turbo Suppliers (www.guoshitrade.com)
Discount Nike Shox Classic Shoes Suppliers (www.guoshitrade.com)
Discount Nike Shox Dendara Trainer (www.guoshitrade.com)
Discount Nike Air Jordan 1 Seller (www.guoshitrade.com)
Discount Nike Air Jordan 2 Shoes Seller (www.guoshitrade.com)
Discount Nike Air Jordan 3 Collection (www.guoshitrade.com)
Discount Nike Air Jordan 4 Shoes Collection (www.guoshitrade.com)
Discount Nike Air Jordan 5 Chaussure Shoes (www.guoshitrade.com)
Discount Nike Air Jordan 6 Catalog (www.guoshitrade.com)
Discount Nike Air Jordan 7 Shoes Catalog (www.guoshitrade.com)
Discount Nike Air Jordan 8 Customized (www.guoshitrade.com)
Discount Nike Air Jordan 9 Shoes Customized (www.guoshitrade.com)
Discount Nike Air Jordan 10 Wholesalers (www.guoshitrade.com)
Discount Nike Jordan 11 Shoes Wholesalers (www.guoshitrade.com)
Discount Nike Air Jordan 12 Factory (www.guoshitrade.com)
Discount Nike Air Jordan 13 Shoes Factory (www.guoshitrade.com)
Discount Nike Air Jordan 14 Shoes Sell (www.guoshitrade.com)
Discount Nike Air Jordan 16 Exporter (www.guoshitrade.com)
Discount Nike Air Jordan 17 Shoes Exporter (www.guoshitrade.com)
Discount Nike Air Jordan 18 Offer (www.guoshitrade.com)
Discount Nike Air Jordan 19 Shoes Offer (www.guoshitrade.com)
Discount Nike Air Jordan 20 Manufacture (www.guoshitrade.com)
Discount Nike Jordan 21 Shoes Manufacture (www.guoshitrade.com)
More detail land, address:www.guoshitrade.com
==============================================================================
TOPIC: Implicit conversion and method call
http://groups.google.com/group/comp.lang.c++/t/1af613b157b9cd86?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Apr 30 2009 8:25 am
From: Victor Bazarov
Vladimir Jovic wrote:
> Victor Bazarov wrote:
>> GeeRay wrote:
>>> Hi all,
>>> how can I create a template class to decorate a type and use it as
>>> the type itself?
>>>
>>> For example:
>>>
>>> I want to do this:
>>>
>>> #include <iostream>
>>> class A
>>> {
>>> public:
>>> A(){};
>>> virtual ~A(){};
>>> void foo(){ std::cout << "foo" << std::endl;};
>>> };
>>>
>>>
>>> template<class T>
>>> class B
>>> {
>>> public:
>>> B(){};
>>> virtual ~B(){};
>>> operator T(){return instance;};
>>> private:
>>> T instance;
>>> };
>>>
>>>
>>>
>>> int main(int argn, char* argv[])
>>> {
>>> B<A> b();
>>
>> Drop the parentheses, otherwise you're declaring a function. My
>> answer assumes that the definition of 'b' is like this:
>>
>> B<A> b;
>>
>>> b.foo();
>>> }
>>>
>>>
>>> Is it possible?
>>
>> No. For the member function calls (like the . you use to access the
>> 'foo' member) the conversions are not considered. You can overload
>> the member access operator for pointers (pretending that your 'B'
>> class is a pointer), like so:
>>
>> template<class T> class B { ...
>>
>> T* operator->() { return &instance; }
>> };
>>
>> , then you could write something like
>>
>> B<A> b;
>> b->foo();
>>
>> which is not necessarily the best syntax, of course...
>
> Another happy solution:
> static_cast< A >(b).foo();
Or just
A(b).foo();
will probably work just as well. But the point is that the OP didn't
want to remember that 'A' was involved. So, your operator() solution is
a bit better in that respect.
> [..]
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
==============================================================================
TOPIC: contiguous in memory
http://groups.google.com/group/comp.lang.c++/t/a5e84c1f1717e18c?hl=en
==============================================================================
== 1 of 2 ==
Date: Thurs, Apr 30 2009 8:33 am
From: "Hicham Mouline"
void f()
{
auto v1;
auto v2; // consecutive in source code
....
}
Are there any guarantees by c++ that the 2 auto variables are such that &v2
== &v1 + sizeof(v1) ? are they contiguous?
if not, my question becomes empirical here
1. under x86-64, is this always true?
2. under x86-64 msvc, is this always true?
3. under x86-64 g++4.x is this always true?
regards,
== 2 of 2 ==
Date: Thurs, Apr 30 2009 8:55 am
From: Victor Bazarov
Hicham Mouline wrote:
> void f()
> {
> auto v1;
> auto v2; // consecutive in source code
"auto" what? You don't have a type specified, and no initialisation to
derive the type from.
> ....
> }
>
> Are there any guarantees by c++ that the 2 auto variables are such that &v2
> == &v1 + sizeof(v1) ? are they contiguous?
No, of course not. Not to mention that the optimizer can omit placing
them in memory altogether.
>
> if not, my question becomes empirical here
A question cannot be empirical. An answer can be.
> 1. under x86-64, is this always true?
Not likely. Why would it differ from the general answer?
> 2. under x86-64 msvc, is this always true?
Ask in the msvc newsgroup.
> 3. under x86-64 g++4.x is this always true?
Ask in the gnu newsgroup.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
==============================================================================
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