487 Commits

Author SHA1 Message Date
Andrey Semashev 0316628863 Reformat and simplify code. 2026-06-21 18:15:19 +03:00
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 01ac4e1a47 Disable operator_brackets_proxy assignment if reference is not assignable.
Use SFINAE to disable operator_brackets_proxy assignment operator is reference
is not assignable from the assignment argument. Also fix the iterator type
in std::declval in noexcept specification.
2025-06-09 12:01:39 +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 da00617e56 Use perfect forwarding in assignment to operator_brackets_proxy.
Also apply noexcept markup to all of the proxy operators.
2025-06-09 04:58:27 +03:00
Andrey Semashev 7c77e52509 Always use operator_brackets_proxy in iterator_facade.
This avoids returning a copy of the value from operator[], which can
be unexpected by users wanting to obtain an address of the value
referenced by the iterator.

We still want to return a proxy instead of the iterator's reference
since the iterator may be holding the value internally, and the iterator
gets destroyed after returning from operator[], so the returned
reference would be dangling.

Closes https://github.com/boostorg/iterator/issues/61.
2025-06-09 03:22:08 +03:00
Andrey Semashev 7e3e9a584e Replace is_copy_constructible+is_trivial with is_trivially_copyable.
For the purpose of selecting operator[] result type, we don't care
whether the value type is trivially default-constructible. So, in order
to avoid using the deprecated in C++26 is_trivial, use is_trivially_copyable
instead of is_copy_constructible+is_trivial.

Closes https://github.com/boostorg/iterator/issues/93.
2025-06-09 02:36:26 +03:00
Andrey Semashev 1372e9afb6 Fix filter_iterator copy/converting constructor.
The constructed iterator would have an invalid end iterator because of
a typo in storage initialization.

Fixes https://github.com/boostorg/iterator/issues/92.
2025-05-24 23:19:45 +03:00
Andrey Semashev 6428e552e4 Nonessential. 2025-04-23 02:55:50 +03:00
Andrey Semashev 1a7996ebd0 Fixed compilation of filter_iterator conversion constructor.
The constructor would attempt to access a private member of the source
iterator, which could have a different type and therefore have that
member inaccessible. Also, the storage forwarding constructor had incorrect
types used in the forwarding expressions, which caused further compilation
errors.

Fixes https://github.com/boostorg/iterator/issues/90.
2025-04-02 00:09:36 +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 e446c6e05c Added indirect_reference_t alias. 2025-02-07 13:36:40 +03:00
Andrey Semashev 8998179e9d Added pointee_t alias. 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 6e6def930f Modernized transform_iterator.hpp, use EBO to store the transform function. 2025-02-07 01:17:55 +03:00
Andrey Semashev 1a58ca89d1 Reformatted reverse_iterator.hpp. 2025-02-07 01:17:55 +03:00
Andrey Semashev 34f703cfb6 Removed workarounds for older compilers from permutation_iterator.hpp. 2025-02-07 01:17:55 +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 fd1445140f Removed usage of FunctionTypes in function_input_iterator.hpp.
This effectively removes usage of MPL in function_input_iterator.hpp and
also simplifies implementation.
2025-02-07 01:17:50 +03:00
Andrey Semashev 8c2fdf6053 Use variadic template expansion in min category deduction in zip_iterator.
This results in marginally faster compile times in modern code bases
where tuples are variadic.
2025-02-06 01:47:49 +03:00
Andrey Semashev aadd90df45 Removed direct usage of MPL from zip_iterator.hpp.
MPL is still used through Boost.Fusion, but that is a matter of
optimizing Boost.Fusion now.
2025-02-06 01:47:49 +03:00
Andrey Semashev dc57bcf319 Modernized filter_iterator.hpp.
Use EBO to minimize wasted storage space if the predicate is an empty class.

Disable default constructing non-class predicates using SFINAE instead
of a static_assert. This will help type traits like is_constructible,
when applied to the iterator type.
2025-02-06 01:47:49 +03:00
Andrey Semashev baf6d06cc2 Modernized iterator_traits.hpp.
Added *_t type traits and removed an oudated macro that was used with
ancient compilers.
2025-02-06 01:47:49 +03:00
Andrey Semashev 6e60ea7a88 Extracted and unified default template parameter handling helpers.
The new eval_if_default helper replaces both ia_dflt_help and
ia_eval_if_default helpers. Additionally, added a new if_default
helper, which expands to the type or the default parameter directly.

The new helpers are placed in separate headers which can be used
without the iterator_adaptor template.
2025-02-06 01:47:43 +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 c22af90b60 Reformat advance.hpp and distance.hpp. 2025-02-06 01:38:24 +03:00
Andrey Semashev b6a41e325c Added a missing include in interoperable.hpp. 2025-02-06 01:38:24 +03:00
Andrey Semashev 0c2eda4bb8 Removed MPL usage from indirect_iterator.hpp. 2025-02-06 01:38:16 +03:00
Andrey Semashev b12874b6ca Removed MPL usage from iterator_facade.hpp. 2025-02-05 18:51:44 +03:00
Andrey Semashev 1875d95019 Removed MPL usage from iterator_adaptor.hpp. 2025-02-05 18:51:44 +03:00
Andrey Semashev 4f5f61e37b Slightly optimized iterator_facade_default_category compilation speed. 2025-02-05 18:51:44 +03:00
Andrey Semashev 5aa1c9fef3 Removed workarounds for older compilers from is_readable_iterator.hpp. 2025-02-05 18:51:44 +03:00
Andrey Semashev d6a68dc6eb Removed workarounds for older compilers from counting_iterator.hpp. 2025-02-05 18:51:44 +03:00
Andrey Semashev e5ee9a6168 Removed unneeded include. 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 d8ce9ddfc7 Removed MPL usage from facade_iterator_category.hpp. 2025-02-05 18:51:44 +03:00
Andrey Semashev 5f713e9b14 Use std::type_identity when possible in counting_iterator.hpp. 2025-02-05 18:51:44 +03:00
Andrey Semashev 12ee53d441 Added type_identity forwarding header. 2025-02-05 18:51:44 +03:00
Andrey Semashev ef40faf620 Replaced leftover boost::true/false_type with std in counting_iterator.hpp.
Also made (unsigned) long long support mandatory.
2025-02-05 18:51:44 +03:00
Andrey Semashev fc99b7a15d Added missing includes for use_default. 2025-02-05 18:51:44 +03:00
Andrey Semashev 241c28018e Converted leftover boost::true/false_type to std in iterator_facade.hpp. 2025-02-05 18:51:44 +03:00
Andrey Semashev 83905b219e Reduced dependency on MPL in iterator_categories.hpp.
Also simplified implementation of type traits using Boost.MP11.
2025-02-05 18:51:44 +03:00
Andrey Semashev 6fab3bbfa4 Removed dependency on MPL from is_lvalue_iterator.hpp.
Also removed workarounds for older compilers and simplified implementation.
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 b30cbf634c Reduced dependency on MPL in minimum_category.hpp. 2025-01-26 20:00:53 +03:00
Andrey Semashev 7ddbf15868 Removed MPL usage from iterator_archetypes.hpp. 2025-01-26 19:08:40 +03:00
Andrey Semashev 4fc0165034 Removed support for ancient complilers for MPL lambdas in is_readable_iterator. 2025-01-26 17:58:48 +03:00
Andrey Semashev bcf94f9e5d Removed MPL usage from pointee and indirect_reference. 2025-01-26 17:57:47 +03:00
Andrey Semashev d6297a553b Removed the BOOST_ITERATOR_CONVERTIBLE helper macro. 2025-01-26 15:55:52 +03:00