Skip to content

workaround for "incompatible string iterator" assertion triggered by default-constructed string iterators #565

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

Merged
merged 2 commits into from
Oct 16, 2015
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ Testing
libs/mime/test/mime-roundtrip
*.a
_build
/.project
18 changes: 17 additions & 1 deletion boost/network/uri/uri.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,44 +108,60 @@ class BOOST_URI_DECL uri {
return uri_parts_.fragment ? uri_parts_.fragment.get() : const_range_type();
}

// hackfix by Simon Haegler, Esri R&D Zurich
// this workaround is needed to avoid running into the "incompatible string iterator" assertion
// triggered by the default-constructed string iterators employed by cpp-netlib (see uri.ipp qi::rule declarations)
#if defined(_MSC_VER) && defined(_DEBUG)
# define CATCH_EMPTY_ITERATOR_RANGE if (range.begin()._Getcont() == 0 || range.end()._Getcont() == 0) { return string_type(); }
#else
# define CATCH_EMPTY_ITERATOR_RANGE
#endif

string_type scheme() const {
const_range_type range = scheme_range();
return range ? string_type(boost::begin(range), boost::end(range))
CATCH_EMPTY_ITERATOR_RANGE
return range ? string_type(boost::begin(range), boost::end(range))
: string_type();
}

string_type user_info() const {
const_range_type range = user_info_range();
CATCH_EMPTY_ITERATOR_RANGE
return range ? string_type(boost::begin(range), boost::end(range))
: string_type();
}

string_type host() const {
const_range_type range = host_range();
CATCH_EMPTY_ITERATOR_RANGE
return range ? string_type(boost::begin(range), boost::end(range))
: string_type();
}

string_type port() const {
const_range_type range = port_range();
CATCH_EMPTY_ITERATOR_RANGE
return range ? string_type(boost::begin(range), boost::end(range))
: string_type();
}

string_type path() const {
const_range_type range = path_range();
CATCH_EMPTY_ITERATOR_RANGE
return range ? string_type(boost::begin(range), boost::end(range))
: string_type();
}

string_type query() const {
const_range_type range = query_range();
CATCH_EMPTY_ITERATOR_RANGE
return range ? string_type(boost::begin(range), boost::end(range))
: string_type();
}

string_type fragment() const {
const_range_type range = fragment_range();
CATCH_EMPTY_ITERATOR_RANGE
return range ? string_type(boost::begin(range), boost::end(range))
: string_type();
}
Expand Down