Groups | Search | Server Info | Login | Register
| Newsgroups | gnu.g++.help |
|---|---|
| Date | 2018-01-25 19:04 -0800 |
| References | <c23417d4-72c6-4190-9650-06e5e606b745@googlegroups.com> <87d11xn2ca.fsf@LkoBDZeT.terraraq.uk> |
| Message-ID | <f440e97e-df9c-49fe-84f7-d1c08377b09b@googlegroups.com> (permalink) |
| Subject | Re: Trouble debugging some STL code |
| From | "davin.pearson@gmail.com" <davin.pearson@gmail.com> |
Thank you for taking the time to fix my bug. It becomes obvious when the solution is presented to me.
On Friday, January 26, 2018 at 8:52:06 AM UTC+13, Richard Kettlewell wrote:
> writes:
> > std::ostream& operator << (std::ostream& o, const std::map<std::string,int>& map)
> > {
> > typename std::map<std::string,int>::iterator it = map.begin();
>
> [...]
>
> > cd ~/lisp++-projects && make 2018/map/map5.run
> > make: Warning: File '2006/libd/libd.o' has modification time 26862 s in the future
> > * Compiling 2018/map/map5.cc DEBUG
> > g++ -g -O0 -std=c++11 -W -Wall -Wpointer-arith -Wformat -ffast-math -fno-permissive -Wno-format-contains-nul -c 2018/map/map5.cc -o 2018/map/map5.o
> > 2018/map/map5.cc: In function ‘std::ostream& operator<<(std::ostream&, const std::map<std::__cxx11::basic_string<char>, int>&)’:
> > 2018/map/map5.cc:16:63: error: conversion from ‘std::map<std::__cxx11::basic_string<char>, int>::const_iterator {aka std::_Rb_tree_const_iterator<std::pair<const std::__cxx11::basic_string<char>, int> >}’ to non-scalar type ‘std::map<std::__cxx11::basic_string<char>, int>::iterator {aka std::_Rb_tree_iterator<std::pair<const std::__cxx11::basic_string<char>, int> >}’ requested
> > typename std::map<std::string,int>::iterator it = map.begin();
> > ^
> > Makefile.mk:66: recipe for target '2018/map/map5.o' failed
> > make: *** [2018/map/map5.o] Error 1
> >
> > Compilation exited abnormally with code 2 at Thu Jan 25 18:45:24
> > Compilation started at: 20180125-184522
> > compilation-start-time=(23145 28402 353882 710000)
> > compilation-stop-time=(23145 28404 423781 491000)
> > Compilation took 2 seconds
> >
> > What gives with the error message? What mm I doing wrong?
>
> You’ve got a const_iterator, you’re trying to convert it to an
> iterator.
>
> At a higher level, arguably what you’re doing wrong is typing out
> complete (incorrect) type names instead of using ‘auto’.
>
> --
> https://www.greenend.org.uk/rjk/
Back to gnu.g++.help | Previous | Next — Previous in thread | Next in thread | Find similar
Trouble debugging some STL code "davin.pearson@gmail.com" <davin.pearson@gmail.com> - 2018-01-24 21:47 -0800
Re: Trouble debugging some STL code Richard Kettlewell <invalid@invalid.invalid> - 2018-01-25 19:52 +0000
Re: Trouble debugging some STL code "davin.pearson@gmail.com" <davin.pearson@gmail.com> - 2018-01-25 19:04 -0800
Re: Trouble debugging some STL code "davin.pearson@gmail.com" <davin.pearson@gmail.com> - 2018-01-28 19:12 -0800
Re: Trouble debugging some STL code Richard Kettlewell <invalid@invalid.invalid> - 2018-01-29 15:36 +0000
Re: Trouble debugging some STL code "davin.pearson@gmail.com" <davin.pearson@gmail.com> - 2018-02-04 19:23 -0800
Re: Trouble debugging some STL code Richard Kettlewell <invalid@invalid.invalid> - 2018-02-05 08:26 +0000
csiph-web