http://groups.google.com/group/comp.lang.c++?hl=en
comp.lang.c++@googlegroups.com
Today's topics:
* Download free IT and Computer Projects - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/564ea41b8850d3c4?hl=en
* cast/assignement operators - 3 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/00280114b34902eb?hl=en
* const correctness - should C++ prefer const member over non-const? - 3
messages, 2 authors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/35cc955f55ea7387?hl=en
* stl help needed - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/fb8d07b1ba882dd2?hl=en
* expression template and FFT - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/0f359f745d567e20?hl=en
* Class objects work like built-in types, but is it worth it? - 1 messages, 1
author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/2c47abdc653f2dd1?hl=en
* vector<const T(*)> vs. vector<T(*)> - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/8dca9788b8075995?hl=en
* Dealing with a Diamond of Death - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/23939507fa6eb9c8?hl=en
* copy from keys from multimap into the vector - 4 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/abc66612050d5014?hl=en
* C/C++ language proposal: Change the 'case expression' from "integral
constant-expression" to "integral expression" - 3 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/a6452a6641b1fc5b?hl=en
* Result of operations on empty multimap? - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/d96d4489ab44e9b4?hl=en
* Why I can't get the correct result - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/77454825337d9113?hl=en
==============================================================================
TOPIC: Download free IT and Computer Projects
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/564ea41b8850d3c4?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Oct 30 2008 3:37 am
From: spirit
A blog for Downloading free projects on Computer and and Information
Technology
freeprojectsonline.blogspot.com
Its kooool try it..
==============================================================================
TOPIC: cast/assignement operators
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/00280114b34902eb?hl=en
==============================================================================
== 1 of 3 ==
Date: Thurs, Oct 30 2008 3:38 am
From: John Doe
Hi,
I am trying to replace the use of the Windows CString class by a
compatible one (CStdString) using std::string , the problem is I cannot
do the following thing :
A)
CString strFullPath;
CStdString& str = strFullPath;
or this :
B)
CStdString strFolder;
m_treeFolder.GetItemText(hItem, strFolder);
with GetItemText defined like this :
BOOL GetItemText(HTREEITEM hItem, CString& strText) const;
The question is in A) case when I assign a CStdString& with a CString
which operator is called, the assignment one, a cast ?
In B) same question should I declare a cast operator ? an assignement one ?
Final question what should I declare to make A) and B) possible ?
== 2 of 3 ==
Date: Thurs, Oct 30 2008 4:06 am
From: Sam
John Doe writes:
> Hi,
>
> I am trying to replace the use of the Windows CString class by a
> compatible one (CStdString) using std::string , the problem is I cannot
> do the following thing :
>
> A)
> CString strFullPath;
> CStdString& str = strFullPath;
>
> or this :
>
> B)
> CStdString strFolder;
> m_treeFolder.GetItemText(hItem, strFolder);
> with GetItemText defined like this :
> BOOL GetItemText(HTREEITEM hItem, CString& strText) const;
>
>
> The question is in A) case when I assign a CStdString& with a CString
> which operator is called, the assignment one, a cast ?
No operator gets called. A reference is, essentially, a pointer. It must
reference, or point, to something. It can't reference/point to an object of
a different class. You must convert the CString object to a CStdString
first, then take its reference:
CString strFullPath;
CStdString strStdStrFullPath(strFullPath);
CStdString &str=strStdStrFullPath;
In this case, you'll need to define an appropriate constructor fo
CStdString, that takes a reference to a CString as a parameter.
Having said all this, after going through something similar myself,
converting a bunch of code that used MS's gawdawful CString, to a
std::string, screwing around with wrapper classes is a wrong approach. The
way to do this is to analyze the code and divide it into mostly independent
sections. Convert, en-masse, one section at a time. Start with a
global search/replace of CString to std::string, then keep compiling it and
fixing all the compilation errors. Provide a few standalone conversion
operators between CString and std::string, that take care of converting them
at boundaries between the sessions. Once everything is done, the conversion
operator can simply be dropped.
== 3 of 3 ==
Date: Thurs, Oct 30 2008 4:13 am
From: John Doe
Sam wrote:
> John Doe writes:
>
>> Hi,
>>
>> I am trying to replace the use of the Windows CString class by a
>> compatible one (CStdString) using std::string , the problem is I
>> cannot do the following thing :
>>
>> A)
>> CString strFullPath;
>> CStdString& str = strFullPath;
>>
>> or this :
>>
>> B)
>> CStdString strFolder;
>> m_treeFolder.GetItemText(hItem, strFolder);
>> with GetItemText defined like this :
>> BOOL GetItemText(HTREEITEM hItem, CString& strText) const;
>>
>>
>> The question is in A) case when I assign a CStdString& with a CString
>> which operator is called, the assignment one, a cast ?
>
> No operator gets called. A reference is, essentially, a pointer. It must
> reference, or point, to something.
>It can't reference/point to an object of a different class.
Is it true even if CStdString has exactly the same method signatures as
a CString ?
==============================================================================
TOPIC: const correctness - should C++ prefer const member over non-const?
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/35cc955f55ea7387?hl=en
==============================================================================
== 1 of 3 ==
Date: Thurs, Oct 30 2008 3:41 am
From: blargg.h4g@gishpuppy.com (blargg)
In article
<8141ce63-f45b-4692-a05b-e6c44b367c7c@e17g2000hsg.googlegroups.com>,
fungus <openglMYSOCKS@artlum.com> wrote:
> On Oct 30, 10:21=A0am, fungus <openglMYSO...@artlum.com> wrote:
> >
> > Ok, maybe I oversimplified it. Supposed operator[]
> > returns a reference to the int:
>
> ...and just before the pedants arrive, suppose it's
> a struct not an int, and I want to access a member
> of the stuct.
>
> my_struct& operator[](int n) { return data[n]; }
> const my_struct& operator[](int n) const { return data[n]; }
>
> Why does the compiler choose the non-const version
> for the RHS of an expression...?
That's a better question. It chooses the non-const version because C++
doesn't overload based on return type or how the caller uses the return
value, only arguments to the function (including the implicit "this"
argument to member functions). I could have sworn "The Design and
Evolution of C++" covered the reason behind this, but I couldn't find a
reference. I'm assuming it would complicate overloading and often not be
desired.
== 2 of 3 ==
Date: Thurs, Oct 30 2008 3:45 am
From: blargg.h4g@gishpuppy.com (blargg)
In article
<bc2244bc-58cd-4e4e-bf20-3c66f04a4bb4@b1g2000hsg.googlegroups.com>, SG
<s.gesemann@gmail.com> wrote:
> On 30 Okt., 10:59, fungus <openglMYSO...@artlum.com> wrote:
> > Bummer. I've got an object which triggers quite
> > a big internal rebuild when you call the non-const
> > version and I just noticed it's doing a lot of
> > rebuilding because of this assumption.
>
> You can explicitly convert your object to a const version if you don't
> want the non-const member function to be called in some cases:
>
> const foo& myConstFoo = myFoo;
> int blah = myConstFoo[42];
But you can't expect users of the class to do this consistently, since
it's quite tedious. Even having a named T& modify( int index ) would be
better. As others have mentioned, a proxy object with an operator T () and
operator = ( T const& ) would be most transparent to the user.
== 3 of 3 ==
Date: Thurs, Oct 30 2008 4:10 am
From: fungus
On Oct 30, 11:41 am, blargg....@gishpuppy.com (blargg) wrote:
> I could have sworn "The Design and Evolution of C++"
> covered the reason behind this, but I couldn't find a
> reference.
Maybe you mean section 3.7.1 ?
--
<\___/>
/ O O \
\_____/ FTB.
http://www.topaz3d.com/ - New 3D editor!
==============================================================================
TOPIC: stl help needed
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/fb8d07b1ba882dd2?hl=en
==============================================================================
== 1 of 3 ==
Date: Thurs, Oct 30 2008 3:46 am
From: James Kanze
On Oct 30, 12:08 am, Juha Nieminen <nos...@thanks.invalid> wrote:
> DJ Dharme wrote:
> > I really like to use stl as much as possible in my code. But
> > I found it really hard to understand by looking into there
> > source code. I have no idea about what iterator traits,
> > heaps and allocators are.
> You don't need to know what iterator traits, heaps or
> allocators are in order to *use* the STL (which is what you
> are saying above).
> Or do you mean that you want to create your own data container
> which works in the same way as the standard library data
> containers?
Isn't this really mainly an issue of providing standard
conformant iterators? I know that the standard does specify a
certain number of container requirements, but I don't see any
place in the standard which depends on them being implemented in
other containers. All of the use of arbitrary containers in the
standard is via iterators. (Almost---the container adapters
would be an exception.)
At any rate, if I were implementing a standard-like container,
I'd certainly concentrate on making the iterators conform. I'd
throw in the relevant typedef's, and use the same names for the
member functions, because that doesn't cost anything; I'd even
model my choice of functions after the standard, providing not
just insert() and erase(), but push_back(), for example, and
back() and front(), if relevant. But I wouldn't waste my time
worrying about allocators, and providing an allocator template
parameter. (For that matter, I'm not alone, since the next
version of the standard will have std::array, which won't have
an allocator either.)
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
== 2 of 3 ==
Date: Thurs, Oct 30 2008 4:17 am
From: DJ Dharme
On Oct 30, 3:46 pm, James Kanze <james.ka...@gmail.com> wrote:
> At any rate, if I were implementing a standard-like container,
> I'd certainly concentrate on making the iterators conform. I'd
> throw in the relevant typedef's, and use the same names for the
> member functions, because that doesn't cost anything; I'd even
> model my choice of functions after the standard, providing not
> just insert() and erase(), but push_back(), for example, and
> back() and front(), if relevant.
>
> --
> James Kanze (GABI Software) email:james.ka...@gmail.com
> Conseils en informatique orientée objet/
> Beratung in objektorientierter Datenverarbeitung
> 9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Thanks James, that is exactly what I was trying to do.
== 3 of 3 ==
Date: Thurs, Oct 30 2008 4:19 am
From: Pete Becker
On 2008-10-30 06:46:22 -0400, James Kanze <james.kanze@gmail.com> said:
> (For that matter, I'm not alone, since the next
> version of the standard will have std::array, which won't have
> an allocator either.)
Hmm, seems like an obvious oversight. std::array does two things: it
provides a fixed size array, and it allocates memory on the stack.
Adding an allocator would allow control over where the array's contents
were allocated, and providing a default allocator could maintain the
current TR1 behavior of allocating on the stack. Of course, you'd have
to be careful not to introduce a non-trivial constructor (since that
would prevent aggregate initialiation), but I'm sure that with some
template magic (enable_if, anyone?) someone could overlay a reasonable
simulation of the current TR1 array. Why didn't the Committee do this?
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)
==============================================================================
TOPIC: expression template and FFT
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/0f359f745d567e20?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Oct 30 2008 3:55 am
From: Hendrik Schober
Peng Yu wrote:
> [...]
> I see a proposal to add rvalue reference in the standard. Is it in the
> standard now? Is there any compiler that supports it?
I just came across this:
http://gcc.gnu.org/projects/cxx0x.html
HTH!
> Peng
Schobi
==============================================================================
TOPIC: Class objects work like built-in types, but is it worth it?
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/2c47abdc653f2dd1?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Oct 30 2008 3:59 am
From: Hendrik Schober
tonytech08 wrote:
> [...]
> But after pondering the responses here, maybe built-in types are the
> "problem" (!). "Everything is an object" (but not a cosmic one), may
> be the way to go. I know enough "low level" programming to hinder my
> own progress probably. Maybe my initial question was wrong. Maybe I
> should have asked: "Why do we still need built-in types?". Which of
> course brings in the "hardware" folks. Software that programs the
> hardware has been the paradigm. Time for software to influence
> hardware?
I haven't done any close-to-hardware programming. Yet I've come
across software that stressed very good desktop computers to their
limits. If "everything is an object" costs, I don't want to have
it. (And if it doesn't, why was there a need to invent C++?)
Schobi
==============================================================================
TOPIC: vector<const T(*)> vs. vector<T(*)>
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/8dca9788b8075995?hl=en
==============================================================================
== 1 of 2 ==
Date: Thurs, Oct 30 2008 4:04 am
From: eiji.anonremail@googlemail.com
Hi all,
I'm facing some uncertainty with const template arguments.
Maybe someone could explain the general strategy.
#include <vector>
int main(int arc, char** argv)
{
std::vector<const int> vec;
const int i = 5;
vec.push_back(i);
vec[0] = 4; //const has gone away
std::vector<const int*> pvec;
const int* pi = new int(5);
pvec.push_back(pi);
*(pvec[0]) = 4; // not possible because const, compile error
return 0;
}
From the first impression, it is not possible to create a vector of
const ints.
But you can do it with pointers.
== 2 of 2 ==
Date: Thurs, Oct 30 2008 4:53 am
From: "dascandy@gmail.com"
On 30 okt, 12:04, eiji.anonrem...@googlemail.com wrote:
> Hi all,
>
> I'm facing some uncertainty with const template arguments.
> Maybe someone could explain the general strategy.
>
> #include <vector>
>
> int main(int arc, char** argv)
> {
> std::vector<const int> vec;
> const int i = 5;
> vec.push_back(i);
> vec[0] = 4; //const has gone away
>
> std::vector<const int*> pvec;
> const int* pi = new int(5);
> pvec.push_back(pi);
> *(pvec[0]) = 4; // not possible because const, compile error
>
> return 0;
>
> }
>
> From the first impression, it is not possible to create a vector of
> const ints.
> But you can do it with pointers.
When you take whatever you put into the vector, you get a copy of it.
That means that your copy is not const, no matter what you put in.
The pointers you put in are not const - the ints they point to are. A
const pointer to a changeable int looks like
int * const x;
==============================================================================
TOPIC: Dealing with a Diamond of Death
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/23939507fa6eb9c8?hl=en
==============================================================================
== 1 of 1 ==
Date: Thurs, Oct 30 2008 4:07 am
From: Pete Becker
On 2008-10-30 06:06:12 -0400, James Kanze <james.kanze@gmail.com> said:
>
> In practice, the largest single use of MI is for one
> implementation class to implement several interfaces. It's true
> that you don't need MI for this; you can always play games with
> forwarding classes. But MI certainly makes it a lot easier.
> (Note that this is the only use of MI that Java supports.) And
> of course, if the interfaces you are implementing extend other
> interfaces, then you need virtual inheritance. And since it
> never hurts, why not make it the default?
"Never hurts" is a bit too strong. It makes access to base elements a
bit slower, and it requires dynamic_cast for conversions that could be
done with static_cast when the base isn't virtual.
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)
==============================================================================
TOPIC: copy from keys from multimap into the vector
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/abc66612050d5014?hl=en
==============================================================================
== 1 of 4 ==
Date: Thurs, Oct 30 2008 4:07 am
From: Obnoxious User
On Wed, 29 Oct 2008 23:15:35 +0000, Juha Nieminen wrote:
> Obnoxious User wrote:
[snip]
>
> Given that the while loop solution only requires 2 lines of code, I
> think it's the easier solution... ;)
On the other hand, if this action is required in multiple
places, then I would prefer some sort of abstraction instead
of a simple while loop.
--
OU
Remember 18th of June 2008, Democracy died that afternoon.
http://frapedia.se/wiki/Information_in_English
== 2 of 4 ==
Date: Thurs, Oct 30 2008 4:15 am
From: James Kanze
On Oct 29, 8:33 pm, puzzlecracker <ironsel2...@gmail.com> wrote:
> I am using while loop for that but I am sure you can do it
> quicker and more syntactically clear with copy function.
> Here is what I do and would like to if someone has a cleaner
> solution:
> vector<string> vec;
> multimap<stirng, int> myMap
> // populate myMap
> multimap<string, int >::iterator iter = myMap.begin();
> while(iter != myMap.end())
> {
> vec.push_back(iter->first)
> }
Do you really want multiple entries in the vector when there are
multiple entries for a single key in the map? If so, something
like the following should work:
template< typename Pair >
struct First
{
typedef Pair argument_type ;
typedef typename Pair::first_type
result_type ;
typename Pair::first_type
operator()( Pair const& obj ) const
{
return obj.first ;
}
} ;
and then:
typedef First< Map::value_type >
Mapper ;
typedef boost::transform_iterator< Mapper, Map::const_iterator >
InitIter ;
std::vector< std::string >
k( InitIter( m.begin(), Mapper() ),
InitIter( m.end(), Mapper() ) ) ;
If you only want each unique key to appear once, then you should
be able to use a boost::filter_iterator on the
transform_iterator.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
== 3 of 4 ==
Date: Thurs, Oct 30 2008 4:19 am
From: James Kanze
On Oct 30, 12:15 am, Juha Nieminen <nos...@thanks.invalid> wrote:
> Given that the while loop solution only requires 2 lines of
> code, I think it's the easier solution... ;)
But it isn't kool, or in:-).
A lot depends on context. If you often have code which can use
the standard algorithms, provided you can map to only the key or
the mapped type, then it's worth writing functional objects
which do this mapping, and using boost::transform_iterator as
arguments to the constructor. For a one of use, on the other
hand, it's really a question of why be simple, when you can be
complicated. Unless, of course, your goal is mainly to show
off.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
== 4 of 4 ==
Date: Thurs, Oct 30 2008 4:23 am
From: James Kanze
On Oct 30, 3:40 am, puzzlecracker <ironsel2...@gmail.com> wrote:
> > Given that the while loop solution only requires 2 lines of
> > code, I think it's the easier solution... ;)
> That's exactly my point. Guys, do you see how this solution
> is verbose, cluttered, and not particularly expressive over my
> traditional solution? Meyers allegedly encourages to use
> transforms, copy and other algorithms in the STL library. And
> I am confident that for this problem, he would still pick a
> stl-like solution. However, using transform, in this case,
> doesn't telegraph your intent
It doesn't. You're transforming the values of a map into
strings (or whatever).
This merits a half a :-). I actually agree with you. But
mainly because despite the contortions of the standard library;
a map conceptually isn't a "container" of objects, but has keys
and values. And you don't want to transform the keys, just copy
them. If you think of a map as a container of key-value pairs,
which is how the standard library views it, then you are
transforming a key-value pair into a key.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
==============================================================================
TOPIC: C/C++ language proposal: Change the 'case expression' from "integral
constant-expression" to "integral expression"
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/a6452a6641b1fc5b?hl=en
==============================================================================
== 1 of 3 ==
Date: Thurs, Oct 30 2008 4:10 am
From: Hendrik Schober
Keith Thompson wrote:
> "robertwessel2@yahoo.com" <robertwessel2@yahoo.com> writes:
>> On Oct 28, 7:42 pm, JoelKatz <dav...@webmaster.com> wrote:
>>> What will be next? "case >=7:"?
>> Frankly I think ranges on the case constant expressions would be a
>> more useful addition while staying with the basic philosophy of the C
>> switch statement. IOW, "case 2...5:", or something along those
>> lines. But still not something I'm loosing sleep over...
>
> Then programmers will inevitably write
>
> case 'A' ... 'Z':
>
> which is non-portable (under EBCDIC it matches '\' and '}').
And why exactly would that be worse than an 'if'-'else' chain
relying on ASCII?
Schobi
== 2 of 3 ==
Date: Thurs, Oct 30 2008 4:30 am
From: Pete Becker
On 2008-10-30 07:10:13 -0400, Hendrik Schober <spamtrap@gmx.de> said:
> Keith Thompson wrote:
>> "robertwessel2@yahoo.com" <robertwessel2@yahoo.com> writes:
>>> On Oct 28, 7:42 pm, JoelKatz <dav...@webmaster.com> wrote:
>>>> What will be next? "case >=7:"?
>>> Frankly I think ranges on the case constant expressions would be a
>>> more useful addition while staying with the basic philosophy of the C
>>> switch statement. IOW, "case 2...5:", or something along those
>>> lines. But still not something I'm loosing sleep over...
>>
>> Then programmers will inevitably write
>>
>> case 'A' ... 'Z':
>>
>> which is non-portable (under EBCDIC it matches '\' and '}').
>
> And why exactly would that be worse than an 'if'-'else' chain
> relying on ASCII?
>
An if-else chain in source code wouldn't rely on ASCII, but on the
source character set, which would, presumably, be EBCDIC when you're
targeting a machine that uses EBCDIC.
switch(ch)
{
case 'A':
case 'B':
case 'C':
case 'D':
...
}
Each character will be properly encoded, even though there are extra
characters in the middle of the capital letters in EBCDIC.
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)
== 3 of 3 ==
Date: Thurs, Oct 30 2008 5:01 am
From: Hendrik Schober
Pete Becker wrote:
> On 2008-10-30 07:10:13 -0400, Hendrik Schober <spamtrap@gmx.de> said:
>
>> Keith Thompson wrote:
>>> "robertwessel2@yahoo.com" <robertwessel2@yahoo.com> writes:
>>>> On Oct 28, 7:42 pm, JoelKatz <dav...@webmaster.com> wrote:
>>>>> What will be next? "case >=7:"?
>>>> Frankly I think ranges on the case constant expressions would be a
>>>> more useful addition while staying with the basic philosophy of the C
>>>> switch statement. IOW, "case 2...5:", or something along those
>>>> lines. But still not something I'm loosing sleep over...
>>> Then programmers will inevitably write
>>>
>>> case 'A' ... 'Z':
>>>
>>> which is non-portable (under EBCDIC it matches '\' and '}').
>> And why exactly would that be worse than an 'if'-'else' chain
>> relying on ASCII?
>>
>
> An if-else chain in source code wouldn't rely on ASCII [...]
I'd expect most of the programmers I worked with, in the
absent of the 'switch' syntax proposed above, to write
if( x>='A' && x<='Z' )
which is just as wrong.
So allowing this for #switch' IMO wouldn't make anything
worse.
Schobi
==============================================================================
TOPIC: Result of operations on empty multimap?
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/d96d4489ab44e9b4?hl=en
==============================================================================
== 1 of 2 ==
Date: Thurs, Oct 30 2008 4:20 am
From: "Moschops"
In moving some code from VS6 to VS2008 (bear with me, this is not a VS
question, I'm just setting context), we find new crashes that weren't there
before and we think they're related to trying an operation on a multimap
that is empty - for example,
std::multimap<double, aStructWeHaveDefined>::iterator low;
low = c.begin() ; // c is empty (i.e. c.empty()==1) but we haven't
checked for it
In VS6 these crashed did not occur, in VS2008 they do. Can anyone tell me
what is supposed to happen? Is there an exception thrown, or does c.begin()
return some value indicating that the multimap is empty, or is it undefined?
I've had a root through Josuttis but he doesn't go into what happens when
you do something so silly as play around with empty multimaps.
Moschops
== 2 of 2 ==
Date: Thurs, Oct 30 2008 4:32 am
From: Pete Becker
On 2008-10-30 07:20:58 -0400, "Moschops" <moschops@notvalid.com> said:
> In moving some code from VS6 to VS2008 (bear with me, this is not a VS
> question, I'm just setting context), we find new crashes that weren't there
> before and we think they're related to trying an operation on a multimap
> that is empty - for example,
>
> std::multimap<double, aStructWeHaveDefined>::iterator low;
> low = c.begin() ; // c is empty (i.e. c.empty()==1) but we haven't
> checked for it
>
> In VS6 these crashed did not occur, in VS2008 they do. Can anyone tell me
> what is supposed to happen?
The behavior is undefined.
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)
==============================================================================
TOPIC: Why I can't get the correct result
http://groups.google.com/group/comp.lang.c++/browse_thread/thread/77454825337d9113?hl=en
==============================================================================
== 1 of 2 ==
Date: Thurs, Oct 30 2008 4:23 am
From: Obnoxious User
On Thu, 30 Oct 2008 01:55:23 -0700, 348892813 wrote:
> I am a student learning C language, I know many of you are good at it. I
> need your help.Thank you.
comp.lang.c
--
OU
Remember 18th of June 2008, Democracy died that afternoon.
http://frapedia.se/wiki/Information_in_English
== 2 of 2 ==
Date: Thurs, Oct 30 2008 4:35 am
From: DJ Dharme
On Oct 30, 1:55 pm, 348892...@qq.com wrote:
> I am a student learning C language, I know many of you are good at it.
> I need your help.Thank you.
> I want to type in a to choose addition, butI can't get the result.
> #include <stdio.h>
> int main()
> {
> char character;
> float fnum,snum;
> printf("Please type in a number:\n");
> scanf("%f%f",&fnum,&snum); <--- You are taking two inputs here
Your First scanf call is taking two numbers
==============================================================================
You received this message because you are subscribed to the Google Groups "comp.lang.c++"
group.
To post to this group, visit http://groups.google.com/group/comp.lang.c++?hl=en
To unsubscribe from this group, send email to comp.lang.c+++unsubscribe@googlegroups.com
To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c++/subscribe?hl=en
To report abuse, send email explaining the problem to abuse@googlegroups.com
==============================================================================
Google Groups: http://groups.google.com/?hl=en
No comments:
Post a Comment