Fixed hollow iterator, but it still breaks inlining.

This commit is contained in:
Davi Reis 2012-04-15 01:10:03 -03:00
parent 48155e5b66
commit ea1cb4709e
2 changed files with 9 additions and 5 deletions

View File

@ -59,10 +59,10 @@ struct hollow_iterator_base
}; };
template <typename container_type, typename iterator> auto make_hollow( template <typename container_type, typename iterator> auto make_hollow(
container_type* v, vector<bool>* p, iterator it) -> container_type* v, const vector<bool>* p, iterator it) ->
hollow_iterator_base<iterator, is_empty<container_type>> { hollow_iterator_base<iterator, is_empty<const container_type>> {
return hollow_iterator_base<iterator, is_empty<container_type>>( return hollow_iterator_base<iterator, is_empty<const container_type>>(
it, is_empty<container_type>(v, p)); it, is_empty<const container_type>(v, p));
} }
} // namespace cxxmph } // namespace cxxmph

View File

@ -30,6 +30,10 @@ int main(int argc, char** argv) {
for (auto it = cbegin; it != cend; ++it) { for (auto it = cbegin; it != cend; ++it) {
if (((*it) % 2) != 0) exit(-1); if (((*it) % 2) != 0) exit(-1);
} }
const vector<bool>* cp(&p);
cbegin = make_hollow(cv, cp, v.begin());
cend = make_hollow(cv, cp, cv->end());
vector<int>::iterator vit1 = v.begin(); vector<int>::iterator vit1 = v.begin();
vector<int>::const_iterator vit2 = v.begin(); vector<int>::const_iterator vit2 = v.begin();
if (vit1 != vit2) exit(-1); if (vit1 != vit2) exit(-1);
@ -37,7 +41,7 @@ int main(int argc, char** argv) {
auto it2 = make_hollow(&v, &p, vit2); auto it2 = make_hollow(&v, &p, vit2);
if (it1 != it2) exit(-1); if (it1 != it2) exit(-1);
typedef is_empty<vector<int>> iev; typedef is_empty<const vector<int>> iev;
hollow_iterator_base<vector<int>::iterator, iev> default_constructed; hollow_iterator_base<vector<int>::iterator, iev> default_constructed;
default_constructed = make_hollow(&v, &p, v.begin()); default_constructed = make_hollow(&v, &p, v.begin());
return 0; return 0;