--- Begin Message ---
Subject: |
Re: bizarre backtrace when trying to initialize std::map with std::pair array |
Date: |
Wed, 27 Jun 2007 19:39:01 -0000 |
User-agent: |
G2/1.0 |
On Jun 27, 2:09 pm, red floyd <address@hidden> wrote:
>
> You error is on 23. sizeof(pairs) is much larger than the number of
> entries, so you're running off the end of pairs[]. You either need to
> use sizeof(pairs)/sizeof(mypair_t), or since it's a run-time value:
>
Yes, thank you. I had seen the array_size template function before,
but it didn't occur to me that having an invalid pointer would cause
the problem I saw. I used it and it all worked, I think. I was about
to write another paragraph about how I still didn't get it, but I
neglected to look down in the sources of insert_unique (std_tree.h:
996) where it's clear that the pointer changed because it was supposed
to, and I just misinterpreted the gdb stacktrace. Now I'm clear about
why the incorrect second iterator blew me up.
> int main()
> {
> std::map<std::string, void(*)()> mymap(pairs, array_size(pairs));
>
> }
I think you meant
std::map<std::string, void(*)()> mymap(paris, pairs
+array_size(pairs)));
right? The second (non-default, non-copy) map constructor takes two
iterators, not an interator and a size.
--- End Message ---
--- Begin Message ---
Subject: |
confirm 8dbc0c0c556ecdefe3808585c65d0aaba7a5d643 |
If you reply to this message, keeping the Subject: header intact,
Mailman will discard the held message. Do this if the message is
spam. If you reply to this message and include an Approved: header
with the list password in it, the message will be approved for posting
to the list. The Approved: header can also appear in the first line
of the body of the reply.
--- End Message ---