201 Commits

Author SHA1 Message Date
Jeremy W. Murphy 286c9885d6 Constrain distance function using is_iterator type trait (#96)
* Constrain distance function using is_iterator type trait

* Add enable_if include

* Fix template syntax in distance function

* Fix syntax issue in distance enable_if

* Test which overload of distance is called

Added a test for custom distance function using Foo struct.

* Fix wrong spelling of std::ptrdiff_t

* Move Foo struct to global scope

* Andrey magic

* Fix headers, add copyright

* Constrain advance to iterators

* Test contraint of advance function with int overload

Added overload for advance function to handle integers.

* Fix enable_if condition for advance function

* Fix template syntax in advance constraint

* Fix advance test

* Remove constexpr specifier

* Make advance overload require conversion in parameter

* Explain choice of type long for n parameter
2026-06-21 18:04:10 +03:00
Andrey Semashev 4dcba468e2 Add is_*_iterator_v variable templates in C++14 and later. 2026-05-13 12:16:22 +03:00
Andrey Semashev e968c3312b Forward dereferencing operators in operator_brackets_proxy.
This allows for expressions like it[n]->foo() and (*it[n]).foo() to compile.
2025-06-09 04:58:45 +03:00
Andrey Semashev c2b846c57d Added a test for filter_iterator converting constructor. 2025-04-02 00:13:07 +03:00
Andrey Semashev eee670608e Revert "Added a workaround for the missing MPL includes in Range."
This reverts commit dfb1fd9bed.

The missing includes were added to Boost.Range, the workaround is
no longer needed.
2025-02-07 14:10:12 +03:00
Andrey Semashev a7150173ed Moved shared_container_iterator.hpp in iterator directory, modernized code.
shared_container_iterator now uses std::shared_ptr to store the reference
to the container. boost::shared_ptr is still supported and is wrapped
into std::shared_ptr on construction, so there is overhead due to allocation
of std::shared_ptr state. Going forward, std::shared_ptr is expected
to be the primary use case. As a bonus, this eliminates the dependency
on Boost.SmartPtr.

Moved shared_container_iterator.hpp into the iterator directory and left
a forwarding header for backward compatibility.
2025-02-07 13:36:40 +03:00
Andrey Semashev d35869cd25 Moved generator_iterator.hpp in iterator directory and modernized.
generator_iterator now uses decltype approach to deduce value and reference
types instead of the legacy result_type typedef, which was required to be
defined by the generator function.

The default constructor of generator_iterator now value initializes its
data members to avoid using uninitialized data.
2025-02-07 13:36:33 +03:00
Andrey Semashev a91fc06bb4 Prohibit default construction of function_output_iterator on function pointers.
Default-constructed function_output_iterator with function pointers is unusable
and previously would have contained an uninitialized function pointer.
Disable the default constructor using SFINAE to prevent misuse.

Also reformat code.
2025-02-07 01:17:55 +03:00
Andrey Semashev cb81a1dfc3 Extracted enable_if_convertible trait to a separate header.
Keep including the new header in iterator_adaptor.hpp for backward
compatibility, until downstream users are updated to include the new
header.
2025-02-06 01:38:24 +03:00
Andrey Semashev dfb1fd9bed Added a workaround for the missing MPL includes in Range.
This is a temporary workaround until Boost.Range is fixed by:

https://github.com/boostorg/range/pull/154
2025-02-05 18:51:44 +03:00
Andrey Semashev 82703b7c14 Moved input_output_iterator_tag to unit tests.
The class was not used anywhere else and was an implementation detail.
2025-02-05 18:51:44 +03:00
Andrey Semashev dec7d0f24c Extracted min_category as a variadic metafunction.
The new min_category is similar to minimum_category but accepts variable
number of iterator categories on input instead of just two, and also does
not depend on Boost.MPL for lambda placeholders. The existing minimum_category
trait has been reimplemented in terms of min_category and deprecated.

We don't yet emit deprecation warnings as there is still code that uses
the old trait which we first need to update. Eventually, minimum_category
will emit warnings and will be removed.
2025-02-05 18:51:37 +03:00
Andrey Semashev 32d19a72e1 Trim trailing spaces. 2025-01-26 15:45:03 +03:00
Andrey Semashev 5ed3144969 Restored the original static assert check. 2025-01-26 15:22:53 +03:00
Georgy Guminov f9effffb6d Mostly remove pre-CXX11 workarounds.
С++03 support was deprecated in 1.85 and now can be removed. This PR clears
many of workarounds, which are no longer needed now.

* Remove unused workaround macros (many of).
* Remove BOOST_STATIC_ASSERT usages.
* Minimize Boost::type_traits dependency (in favour of STL's type_traits).

Closes https://github.com/boostorg/iterator/pull/82.

Squashed commit of the following:

commit 741a627b73
Author: Georgy Guminov <gogagum@gmail.com>
Date:   Sat Jan 25 12:13:05 2025 +0300

    Replace testers with standard metafunctions.

commit bf4cce6114
Author: Georgy Guminov <gogagum@gmail.com>
Date:   Sat Jan 25 11:51:32 2025 +0300

    Refactor is_lvalue_iterator.hpp.

commit 8d080c6c58
Author: Georgy Guminov <gogagum@gmail.com>
Date:   Sat Jan 25 10:27:32 2025 +0300

    Remove more workarounds.

commit 5a4ba24d36
Author: Georgy Guminov <gogagum@gmail.com>
Date:   Sun Jan 19 16:38:30 2025 +0300

    Fixes.

commit fdfafce2b9
Author: Georgy Guminov <gogagum@gmail.com>
Date:   Sat Oct 26 15:06:43 2024 +0300

    Remove BOOST_NO_STRICT_ITERATOR_INTEROPERABILITY
    Correct static_assert messages.
    Fix messages & replace is_standard_layout with is_copy_constructible.

commit c69ac1408a
Author: Georgy Guminov <gogagum@gmail.com>
Date:   Sat Oct 26 14:48:51 2024 +0300

    Correct static_assert messages.

commit b5df827151
Author: Georqy Guminov <gogagum@gmail.com>
Date:   Sun Jun 23 16:12:29 2024 +0300

    Fixes. Remove some Boost.MPL usages. Remove unused includes.

commit 01fd35e9f8
Author: Georgiy Guminov <gogagum@gmail.com>
Date:   Wed Jun 12 17:14:21 2024 +0300

    abstract conjunction.

commit c02def8acf
Author: Georgiy Guminov <gogagum@gmail.com>
Date:   Wed Jun 12 16:35:43 2024 +0300

    return addressof & conjunction.

commit 3b3d162575
Author: Georgiy Guminov <gogagum@gmail.com>
Date:   Wed Jun 12 16:30:44 2024 +0300

    Make macro more readable.

commit 4ab19e045f
Author: Georgiy Guminov <gogagum@gmail.com>
Date:   Wed Jun 12 15:56:49 2024 +0300

    Add static_assert messages.

commit 82b5c44cd3
Author: Georgiy Guminov <gogagum@gmail.com>
Date:   Wed Jun 12 14:12:10 2024 +0300

    Return is iterator CXX17 test.

commit 2d58d65462
Author: Georgiy Guminov <gogagum@gmail.com>
Date:   Tue Jun 11 14:04:17 2024 +0300

    Omitted.

commit a0d04d9491
Author: Georgiy Guminov <gogagum@gmail.com>
Date:   Tue Jun 11 14:00:35 2024 +0300

    Replace move with static_cast

commit 4a49b8a1a2
Author: Georgiy Guminov <gogagum@gmail.com>
Date:   Mon Jun 10 21:38:53 2024 +0300

    Return BOOST_NOEXCEPT

commit 054c013bba
Author: Georgiy Guminov <gogagum@gmail.com>
Date:   Sun Jun 9 15:20:41 2024 +0300

    CXX11
2025-01-26 15:21:16 +03:00
Andrey Semashev 4b40364d6d Work around compilation errors on clang-10 through 12. 2024-10-11 01:04:21 +03:00
Georgiy Guminov 1ea8087623 Check for compliance with output_iterator in function_output_iterator_test. 2024-10-11 00:29:20 +03:00
René Ferdinand Rivera Morell ce030ab2c3 Add support for modular build structure. (#84)
* Make the library modular usable.

* Switch to library requirements instead of source. As source puts extra source in install targets.

* Remove not-needed reference to Conversion dependency.

* Add missing b2 testing module import.

* Add requires-b2 check to top-level build file.

* Bump B2 require to 5.2

* Change all <source> references to <library>.

* Update copyright dates.

* Move inter-lib dependencies to a project variable and into the build targets.

* Update build deps.
2024-08-19 01:22:08 +03:00
Andrey Semashev ae5d7d8c0c Added a CMake test. 2023-11-17 17:47:20 +03:00
Andrey Semashev a9dabd3c65 Removed dependency on Boost.Conversion in tests.
This reduces the minimum supported compilers versions.
2023-11-17 04:25:29 +03:00
Andrey Semashev 85b542e1b6 Extracted is_iterator trait to a separate header.
Also, reworked is_iterator to be more robust against various corner cases
and added dedicated tests for the type trait.
2023-05-21 15:18:54 +03:00
Alexander Grund e8fbd92a61 Use BOOST_STATIC_ASSERT instead of BOOST_MPL_ASSERT (#78)
The MPL version is slower to compile and `BOOST_STATIC_ASSERT` is
already used in some places. So unify that.

This also fixes `Wzero-as-null-pointer-constant` warnings, see https://github.com/boostorg/mpl/pull/75
2023-05-07 15:23:16 +03:00
Andrey Semashev 7c9b4296a1 Fixed accessing members of the dereferenced value after iterator post-increment.
The recent commit 5777e9944b broke code such as
(*it++).foo(), where the result of dereferencing would be convertible to
the value type but did not provide the members of the value type. To mitigate
this, return a reference to the value instead of a proxy object. This will only
work for non-writable iterators (and it didn't work for writable iterators
before either) because in that case a proxy is needed to be able to intercept
operator=.

Also fix a similar issue with (it++)->foo() by adding operator-> overloads
to the post-increment result proxies.

Added tests for the fixes.
2022-11-18 00:46:21 +03:00
Andrey Semashev 0a95636faf Added test for converting func_input_iter increment results to the iterator type. 2022-11-09 21:19:00 +03:00
Andrey Semashev 129245a985 Added tests for function_output_iterator. 2022-07-01 00:14:14 +03:00
Andrey Semashev eb0d01126a Added support for int128 to counting_iterator. 2022-01-13 16:59:46 +03:00
Andrey Semashev abe6fbfd4b Converted counting_iterator to rely on TypeTraits instead of MPL. 2022-01-13 16:57:52 +03:00
Andrey Semashev 1c6f85d4f9 Fixed a preprocessor condition. 2021-09-12 23:36:59 +03:00
Andrey Semashev 0a59f555ca Added libc++ 12 to the list of standard libs implementing C++20 std::ostream_iterator. 2021-09-12 22:52:55 +03:00
Andrey Semashev 18337e990b Disable zip_iterator test with std::tuple on gcc 4.4.
libstdc++ from gcc 4.4 has a broken std::tuple that fails to compile
a constructor from a compatible tuple:

/usr/include/c++/4.4/tuple: In constructor 'std::_Head_base<_Idx, _Head, false>::_Head_base(_UHead&&) [with _UHead = std::_Head_base<0ul, const int&, false>, long unsigned int _Idx = 0ul, _Head = int]':
/usr/include/c++/4.4/tuple:179:   instantiated from 'std::_Tuple_impl<_Idx, _Head, _Tail ...>::_Tuple_impl(std::_Tuple_impl<_Idx, _UElements ...>&&) [with _UElements = const int&, double&, long unsigned int _Idx = 0ul, _Head = int, _Tail = double]'
/usr/include/c++/4.4/tuple:338:   instantiated from 'std::tuple<_T1, _T2>::tuple(std::tuple<_U1, _U2>&&) [with _U1 = const int&, _U2 = double&, _T1 = int, _T2 = double]'
libs/iterator/test/detail/zip_iterator_test_original.ipp:137:   instantiated from here
/usr/include/c++/4.4/tuple:94: error: cannot convert 'std::_Head_base<0ul, const int&, false>' to 'int' in initialization
2021-09-12 22:40:19 +03:00
Glen Fernandes f4b47fd266 Switch from deprecated test to Lightweight Test 2021-06-07 22:03:32 -04:00
Casey Carter 32f4f4d086 MSVC also has C++20 output_iterator
Tell iterator_traits_test not to fail on MSVC when `std::output_iterator` has `difference_type` of `std::ptrdiff_t`.
2020-10-13 19:23:49 -07:00
Andrey Semashev 72f0ebe8d0 Adjusted the check for C++20 on gcc 10.
The compiler defines __cplusplus to a non-standard value less than 202002
in C++20 mode.
2020-05-24 00:29:51 +03:00
Andrey Semashev d7ad43a925 Updated to support C++20 ostream_iterator::difference_type on gcc 10. 2020-05-23 19:57:54 +03:00
Andrey Semashev 5b18ae976e Updated code to use distance and iterator_traits from std. 2020-05-10 23:08:14 +03:00
Andrey Semashev da8604615e Removed the use of deprecated header boost/detail/iterator.hpp 2020-05-10 23:02:42 +03:00
Edward Diener dc7bf5cc05 Change __BORLANDC__ to BOOST_BORLANDC, which is defined in Boost config for the Embarcadero non-clang-based compilers. 2020-03-31 11:21:59 -04:00
Andrey Semashev 80ec58bb3b Trim trailing spaces. 2020-03-04 01:06:45 +03:00
Andrey Semashev c2929ea6c6 Updated to use boost/bind/bind.hpp to avoid warnings and compliance with C++20.
boost/bind.hpp emits warnings about deprecating global placeholder argument
keywords. C++20 removes std::bind1st/bind2nd, so replaced their usage with
boost::bind.
2020-03-04 01:02:52 +03:00
Andrey Semashev 4fe679bb0d Updated lightweight_test.hpp includes to the new location. 2020-03-04 00:52:58 +03:00
Andrey Semashev 3cc4107d01 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).
2018-09-23 12:37:21 +03:00
morinmorin 194087e8ca Merge branch 'develop' into fix/unwanted_adl 2018-09-22 20:47:10 +09:00
morinmorin b5edc8b64f Add test for ADL issues. 2018-09-22 20:44:29 +09:00
Daniela Engert e16f2de233 Inheriting std::iterator is deprecated in c++17.
Boost's iterator.hpp is deprecated, too. Therefore get rid of all of that and replace inheritance by lifting std::iterator's members into the derived class.

Signed-off-by: Daniela Engert <dani@ngrt.de>
2017-12-27 09:32:51 +01:00
Peter Dimov 0013c5c4f0 Skip zip_iterator_test_std_pair on g++ in C++03 mode 2017-12-24 04:56:47 +02:00
Peter Dimov 386dbf1054 Skip zip_iterator_test_std_pair on msvc-9.0 and below 2017-12-24 04:38:07 +02:00
Peter Dimov adecfd94f3 Use lightweight_test in shared_iterator_test.cpp 2017-12-23 23:45:59 +02:00
Peter Dimov affe7e6d84 Add shared_iterator_test to test/Jamfile 2017-12-23 23:45:33 +02:00
Peter Dimov 91b392a478 Move test files to test/ 2017-12-23 22:05:35 +02:00
Peter Dimov 81faa161cf Add #include <boost/next_prior.hpp>; no longer in utility.hpp 2017-12-02 04:04:32 +02:00