Skip to content

Commit

Permalink
fixed question bug based on Mooophy/Cpp-Primer#105
Browse files Browse the repository at this point in the history
  • Loading branch information
pezy committed Dec 23, 2014
1 parent c657dfc commit 3a6e3f3
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions ch09/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,21 @@ const vector<int> v2;
auto it1 = v1.begin(), it2 = v2.begin();
auto it3 = v1.cbegin(), it4 = v2.cbegin();
```
In gcc 4.8, will report error:
error: inconsistent deduction for ‘auto’: ‘__gnu_cxx::__normal_iterator<int*, std::vector<int> >’ and then ‘__gnu_cxx::__normal_iterator<const int*, std::vector<int> >’ auto it1 = v1.begin(), it2 = v2.begin();
the correct code should be

-----

[@shidenggui](https://github.com/shidenggui):

The question example codes have an error in `gcc 4.8`:
>**error**: inconsistent deduction for ‘auto’: ‘__gnu_cxx::__normal_iterator<int*, std::vector<int> >’ and then ‘__gnu_cxx::__normal_iterator<const int*, std::vector<int> >’ auto it1 = v1.begin(), it2 = v2.begin();
the correct codes should be:
```cpp
auto it1 = v1.begin();
auto it2 = v2.begin(), it3 = v1.cbegin(), it4 = v2.cbegin();
auto it2 = v2.begin(), it3 = v1.cbegin(), it4 = v2.cbegin();
```

-----

`it1` is `vector<int>::iterator`

Expand Down

0 comments on commit 3a6e3f3

Please sign in to comment.