Added a test for compatibility of boost::distance between Range and Iterator.

This functionality is used in core Boost components, so it is preferable
to test it in Boost.Iterator, even if it's already tested in Boost.Range,
to discover problems as early as possible.

The test verifies that boost::distance implemented in Boost.Range can invoke
boost::distance in Boost.Iterator (i.e. the function lookup succeeds).
This commit is contained in:
Andrey Semashev 2018-09-23 12:37:21 +03:00
parent 6ab148be01
commit 3cc4107d01
2 changed files with 23 additions and 0 deletions

View File

@ -60,6 +60,7 @@ test-suite iterator
[ run advance_test.cpp ]
[ run distance_test.cpp ]
[ compile adl_test.cpp ]
[ compile range_distance_compat_test.cpp ]
[ run shared_iterator_test.cpp ]
;

View File

@ -0,0 +1,22 @@
// Copyright (C) 2018 Andrey Semashev
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <boost/range/distance.hpp>
#include <boost/range/iterator_range_core.hpp>
#include <boost/iterator/distance.hpp>
int main()
{
// Test that boost::distance from Boost.Range works with boost::distance from Boost.Iterator
// (https://github.com/boostorg/iterator/commit/b844c8df530c474ec1856870b9b0de5f487b84d4#commitcomment-30603668)
typedef boost::iterator_range<const char*> range_type;
range_type range;
(void)boost::distance(range);
return 0;
}