C, C++, VC++ Etc.

Re: Is a std::map<> ordered?

comp.lang.c++ Google Group - Thu, 2008-11-20 15:35
Hmmm. I mean map values are sorted by keys. Of course, I mistyped
with "is", but where I said about values?
Ya, you are right. When read FFMG's last question I think that he
wants to sort map. Of course, map elements order cannot be changed.

Re: Is a std::map<> ordered?

comp.lang.c++ Google Group - Thu, 2008-11-20 15:35
No, this is incorrect. A map is always sorted using std::less on the
key (not the value).
It cannot be reordered.
Joe Cook

Re: Is a std::map<> ordered?

comp.lang.c++ Google Group - Thu, 2008-11-20 15:35
According to the Bjarne map values is sorted by keys (17.4.1)
Use sort()

Re: Is a std::map<> ordered?

comp.lang.c++ Google Group - Thu, 2008-11-20 15:35
FFMG schrieb:
A map is always ordered by the key. So the order would be 100, 150, 200,
300 with the corresponding values.
[...]
You can't reorder a map. A std::map (and std::set) is always ordered by
the key, using the given predicate function, which is std::less by default.

Re: BYTE array size

comp.lang.c++ Google Group - Thu, 2008-11-20 15:35
Chunekit Pong <worlman...@yahoo.com> wrote in
Why bother to make pbBinary and size ?
Why not:
BOOL fRet = ::CryptBinaryToString(&bytes[0 ], bytes.size(),
CRYPT__STRING_BASE64, pEncOut, &ulEncLen);
?

Is a std::map<> ordered?

comp.lang.c++ Google Group - Thu, 2008-11-20 15:35
Hi,
If I have something like :
std::map<int, int> myMap;
myMap[200] = 1;
myMap[100] = 2;
myMap[300] = 3;
myMap[150] = 4;
What does the standard say that the output must be if I iterate thru
the map?
for( std::map< int, int>::const_iterator it = myMap.begin(); it !=
myMap.end(); ++it )
{
// output it->first

Re: BYTE array size

comp.lang.c++ Google Group - Thu, 2008-11-20 15:35
The previous posters have explained the problem. A possible fix to
your program:
Instead of:
int size = sizeof(pbBinary);
Try:
int size = bytes.size();

Re: Garbage collection in C++

comp.lang.c++ Google Group - Thu, 2008-11-20 15:35
Juha was saying that certain applications (or algorithms, in general)
can't be run in a GC'd environment on the same problem size as they can
in a manually managed environment, which is just plain false. Of course
a, say, Unix process may have some more memory mapped to it if that's
still in the GC's memory pool internally just as it also happens with

Do checked iterators/containers make code more secure?

comp.lang.c++ Google Group - Thu, 2008-11-20 15:35
Hi,
Does usage of checked iterators and checked containers make code more
secure?
If so, can that code considered to be reasonably secure?

Re: Garbage collection in C++

comp.lang.c++ Google Group - Thu, 2008-11-20 15:35
Ah, someone's got the point I was trying to make, thank you!

Re: Is C++ the "General Motors" of Programming Languages?

comp.lang.c++ Google Group - Thu, 2008-11-20 15:35
Nah. It's more like a Honda Motor Co., actually. I would rather
probably liken *Fortran* to GM.
V

Re: BYTE array size

comp.lang.c++ Google Group - Thu, 2008-11-20 15:35
Ask whoever created the array to tell you. Once the array has
been converted to a pointer to the first element, all
information concerning the size has been lost.
A better solution might be to use std::vector.

Re: BYTE array size

comp.lang.c++ Google Group - Thu, 2008-11-20 15:35
I know what you mean, but you really should say that you can't
get the size of an array given a pointer to its first element.
(Pointers to arrays, i.e. BYTE (*p)[ 200 ], exist, and in such
cases, sizeof( *p ) would be useful. But they aren't very
idiomatic.)
If something is declared as an array, it's not a pointer.

Re: Acessing the "time" Part of time_t Value

comp.lang.c++ Google Group - Thu, 2008-11-20 15:35
That depends on how precise and how portable you have to be.
Not all days have exactly 86400 seconds, and time_t can be any
numeric type, with any representation---if it uses the
representation that was current in MS-DOS, your results are
meaningless, and if it is a double, your solution won't even
compile. (But for a lot of uses, it's adequate. It's what I

std::vector<>::iterator and recognizable bounds

comp.lang.c++ Google Group - Thu, 2008-11-20 15:35
Hi folks.
I have a function that takes an element in a vector as
argument. The naive interface goes as
float computeSomething(const std::vector<float>& v, size_t i)
{
size_t j = i-1;
size_t k = i+1;
if (j<0){/* Handle start boundary condition */}
if (k>=v.size()){/* Handle terminal boundary condition */}

Re: Garbage collection in C++

comp.lang.c++ Google Group - Thu, 2008-11-20 15:35
What you want seems to be a "scope guard". A Lambda-based scope guard
could be used like this:
template<typename F> requires Callable<F> && MoveConstructible<F>
class scope_guard { /* ... library magic ... */ };
template<typename F> requires Callable<F> && MoveConstructible<F>
scope_guard<F> make_scope_guard(F f);

Google