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

minor issues in <xutility> #3703

Closed
achabense opened this issue May 15, 2023 · 2 comments
Closed

minor issues in <xutility> #3703

achabense opened this issue May 15, 2023 · 2 comments
Labels
invalid This issue is incorrect or by design

Comments

@achabense
Copy link
Contributor

achabense commented May 15, 2023

Below is the current code in <xutility>. At line 879, it seems incrementable_traits lacks _EXPORT_STD.

And as to projected at line 867, it seems the definition of operator*() is not needed. (cppreference:"projected is used only to constrain algorithms that accept callable objects and projections, and hence its operator*() is not defined.")
image

@achabense achabense changed the title <xutility> minor fix <xutility> minor issues May 15, 2023
@achabense achabense changed the title <xutility> minor issues minor issues in <xutility> May 15, 2023
@achabense achabense changed the title minor issues in <xutility> minor bug(s) in <xutility> May 15, 2023
@frederick-vs-ja
Copy link
Contributor

  1. <xutility> only provides a partial specialization of incrementable_traits, while the primary template is defined in <__msvc_iter_core.hpp> and exported. Whenever the primary template is exported, so are its specializations, and thus it's totally fine to omit _EXPORT_STD here
    _EXPORT_STD template <class>
    struct incrementable_traits {};
  2. The function body is a permanent workaround for a bug of MSVC (see Standard Library Header Units and Modules - tracking issue #1694), so perhaps it's not time to remove it at this moment. Although I'm not sure whether _STL_UNREACHABLE would be better.

@achabense achabense changed the title minor bug(s) in <xutility> ~~minor bug(s)~~ in <xutility> May 15, 2023
@achabense achabense changed the title ~~minor bug(s)~~ in <xutility> minor bug(s) in <xutility> May 15, 2023
@achabense achabense changed the title minor bug(s) in <xutility> minor issues in <xutility> May 15, 2023
@StephanTLavavej
Copy link
Member

@achabense In the future, when reporting issues, it's better to use GitHub permalinks instead of screenshots. This makes navigating to the source file and context easy, allows copy-pasting, and is more accessible. For example, if I mention:

https://github.com/microsoft/STL/blob/5404ba9c25f26f25a0ac50e6c4defce7833a8da6/stl/inc/xutility#L866-L882

then it's displayed as:

STL/stl/inc/xutility

Lines 866 to 882 in 5404ba9

_EXPORT_STD template <indirectly_readable _It, indirectly_regular_unary_invocable<_It> _Proj>
struct projected {
using value_type = remove_cvref_t<indirect_result_t<_Proj&, _It>>;
indirect_result_t<_Proj&, _It> operator*() const {
_CSTD abort();
}
};
template <class _It, class _Proj>
struct _Indirect_value_impl<projected<_It, _Proj>> {
using type = invoke_result_t<_Proj&, _Indirect_value_t<_It>>;
};
template <weakly_incrementable _It, class _Proj>
struct incrementable_traits<projected<_It, _Proj>> {
using difference_type = iter_difference_t<_It>;
};

See Creating a permanent link to a code snippet.

@CaseyCarter CaseyCarter added the invalid This issue is incorrect or by design label May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This issue is incorrect or by design
Projects
None yet
Development

No branches or pull requests

4 participants