Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS2017 build fix for #1187 #1188

Merged
merged 1 commit into from
Aug 28, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions src/osgEarthFeatures/FeatureSourceIndexNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,17 @@ namespace
{
// nifty template to iterate over a map's keys
template<typename T>
struct KeyIter : public T::iterator
struct KeyIter : public std::iterator<std::input_iterator_tag, typename T::value_type>
{
KeyIter() : T::iterator() { }
KeyIter(typename T::iterator i) : T::iterator(i) { }
typename T::key_type* operator->() { return (typename T::key_type* const)&(T::iterator::operator->()->first); }
typename T::key_type operator*() { return T::iterator::operator*().first; }
};

template<typename T>
struct ConstKeyIter : public T::const_iterator
{
ConstKeyIter() : T::const_iterator() { }
ConstKeyIter(typename T::const_iterator i) : T::const_iterator(i) { }
typename T::key_type* operator->() { return (typename T::key_type* const)&(T::const_iterator::operator->()->first); }
typename T::key_type operator*() { return T::const_iterator::operator*().first; }
typename T::const_iterator it;
KeyIter(typename T::const_iterator i) : it(i) { }
KeyIter &operator++() { ++it; return *this; }
KeyIter operator++(int) { KeyIter t = *this; ++*this; return t; }

typename T::key_type const *operator->() const { return &(it->first); }
typename T::key_type const &operator*() const { return it->first; }
friend bool operator==(KeyIter const &a, KeyIter const &b) { return a.it == b.it; }
friend bool operator!=(KeyIter const &a, KeyIter const &b) { return a.it != b.it; }
};
}

Expand Down Expand Up @@ -99,7 +95,7 @@ FeatureSourceIndexNode::~FeatureSourceIndexNode()
{
// must copy and clear the original list first to dereference the RefIDPair instances.
std::set<FeatureID> fidsToRemove;
fidsToRemove.insert( KeyIter<FIDMap>(_fids.begin()), KeyIter<FIDMap>(_fids.end()) );
fidsToRemove.insert(KeyIter<FIDMap>(_fids.begin()), KeyIter<FIDMap>(_fids.end()));
_fids.clear();

OE_DEBUG << LC << "Removing " << fidsToRemove.size() << " fids\n";
Expand Down Expand Up @@ -137,9 +133,9 @@ FeatureSourceIndexNode::tagNode(osg::Node* node, Feature* feature)
bool
FeatureSourceIndexNode::getAllFIDs(std::vector<FeatureID>& output) const
{
ConstKeyIter<FIDMap> start( _fids.begin() );
ConstKeyIter<FIDMap> end ( _fids.end() );
for(ConstKeyIter<FIDMap> i = start; i != end; ++i )
KeyIter<FIDMap> start( _fids.begin() );
KeyIter<FIDMap> end ( _fids.end() );
for(KeyIter<FIDMap> i = start; i != end; ++i )
{
output.push_back( *i );
}
Expand Down