On 10/18/24 11:21 AM, Patrick Palka wrote:
On Fri, 18 Oct 2024, Jason Merrill wrote:
Is it useful for std.cc to live in a subdirectory of c++23 as in this patch, or
should it be in c++23 itself? Or elsewhere?
IIUC the src/ subdirectory is for stuff that gets compiled into the .so
which isn't the case here.
Sure, though I thought that might change once we consider it ABI-stable.
And if we want to support the std module in
C++20 mode as an extension, a c++23 subdirectory might not be ideal either.
My impression has been that the subdirectories are just for organization?
Maybe libstdc++-v3/modules/ then?
Let's see what Jonathan thinks.
On 10/18/24 12:04 PM, Maciej Cencora wrote:
On Fri, 18 Oct 2024, Jason Merrill wrote:
stdc++.h also doesn't include the eternally deprecated <strstream>. There
are some other deprecated facilities that I notice are included: <codecvt>
and float_denorm_style, at least. It would be nice for L{E,}WG to clarify
whether module std is intended to include interfaces that were deprecated in
C++23, since ancient code isn't going to be relying on module std.
Per P2465r3 Standard Library Modules std and std.compat:
Are deprecated features provided by the Standard Library modules?
Yes. This is implied by the normative wording.
Ah, thanks.
While doing some light testing, one thing that immediately popped up is that we
need to export __normal_iterator related operators from __gnu_cxx namespace.
Otherwise it is impossible to even use std::vector in range-based for loops.
Ah, good catch.
But I think a better solution (than exporting such impl details) is to make
these operators hidden friends.
That sounds right to me, and mechanically duplicating the declarations
as friends seems to work (as attached).
Another thing - P2465r3 mentions only lerp, byte and related ops as special
w.r.t skipping export from global namespace in std.compat, but for some reason
Microsoft's impl treats 3-arg hypot as special as well.
Curious. By not declaring it at all when building the module? I don't
want to mess with that if the standard doesn't require it.
On 10/18/24 12:35 PM, Iain Sandoe wrote:
Currently this installs the sources under $(pkgdata), i.e.
/usr/share/libstdc++/modules. It could also make sense to install them
under $(gxx_include_dir), i.e. /usr/include/c++/15/modules. And/or the
subdirectory could be "miu" (module interface unit) instead of "modules".
I’d think that $(gxx_include_dir)/modules would be a good place, since that
allows us to tie it to the GCC version in side-by-side installs. Presumably
that
might also simplify finding the relevant sources?
With side-by-side installs presumably $(prefix) would be different
between them as well or the libraries would also clash?
But I'm certainly not opposed to putting them under the include dir,
that had been my inclination for a while, and with my
-fsearch-include-path patch would make a simple compile easier without
needing to teach the driver to parse the json.
I guess it could be just “module”, but my vote would be for an obvious name
like that or “std-module”
Indeed singular "module" would be more consistent with "include" and "lib".
On 10/19/24 8:08 AM, Florian Weimer wrote:
The build system can find this file with
gcc -print-file-name=libstdc++.modules.json
Is it possible to use specs file to redirect this to a different file
based on C++ compiler flags, should that become necessary?
Well, the compiler looks up a -print-file-name argument on its library
search path, which can be added to with -B. But this is really an
initial interface pending something more stable.
Jason
From a86905267aeca9892003d11e7292d7e90b82703d Mon Sep 17 00:00:00 2001
From: Jason Merrill <ja...@redhat.com>
Date: Mon, 21 Oct 2024 11:36:41 -0400
Subject: [PATCH] libstdc++: normal_iterator friends
To: gcc-patches@gcc.gnu.org
libstdc++-v3/ChangeLog:
* include/bits/stl_iterator.h: add friends
---
libstdc++-v3/include/bits/stl_iterator.h | 149 +++++++++++++++++++++++
1 file changed, 149 insertions(+)
diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h
index 26c5eab4b4e..611b51adfd8 100644
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -1158,8 +1158,157 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const _Iterator&
base() const _GLIBCXX_NOEXCEPT
{ return _M_current; }
+
+#if __cpp_lib_three_way_comparison
+ template<typename _IteratorL, typename _IteratorR, typename _ContainerF>
+ friend constexpr bool
+ operator==(const __normal_iterator<_IteratorL, _ContainerF>& __lhs,
+ const __normal_iterator<_IteratorR, _ContainerF>& __rhs)
+ noexcept(noexcept(__lhs.base() == __rhs.base()))
+ requires requires {
+ { __lhs.base() == __rhs.base() } -> std::convertible_to<bool>;
};
+ template<typename _IteratorL, typename _IteratorR, typename _ContainerF>
+ friend constexpr std::__detail::__synth3way_t<_IteratorR, _IteratorL>
+ operator<=>(const __normal_iterator<_IteratorL, _ContainerF>& __lhs,
+ const __normal_iterator<_IteratorR, _ContainerF>& __rhs)
+ noexcept(noexcept(std::__detail::__synth3way(__lhs.base(), __rhs.base())));
+
+ template<typename _IteratorF, typename _ContainerF>
+ friend constexpr bool
+ operator==(const __normal_iterator<_IteratorF, _ContainerF>& __lhs,
+ const __normal_iterator<_IteratorF, _ContainerF>& __rhs)
+ noexcept(noexcept(__lhs.base() == __rhs.base()))
+ requires requires {
+ { __lhs.base() == __rhs.base() } -> std::convertible_to<bool>;
+ };
+
+ template<typename _IteratorF, typename _ContainerF>
+ friend constexpr std::__detail::__synth3way_t<_IteratorF>
+ operator<=>(const __normal_iterator<_IteratorF, _ContainerF>& __lhs,
+ const __normal_iterator<_IteratorF, _ContainerF>& __rhs)
+ noexcept(noexcept(std::__detail::__synth3way(__lhs.base(), __rhs.base())));
+#else
+ // Forward iterator requirements
+ template<typename _IteratorL, typename _IteratorR, typename _ContainerF>
+ __attribute__((__always_inline__)) _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
+ friend inline bool
+ operator==(const __normal_iterator<_IteratorL, _ContainerF>& __lhs,
+ const __normal_iterator<_IteratorR, _ContainerF>& __rhs)
+ _GLIBCXX_NOEXCEPT;
+
+ template<typename _IteratorF, typename _ContainerF>
+ __attribute__((__always_inline__)) _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
+ friend inline bool
+ operator==(const __normal_iterator<_IteratorF, _ContainerF>& __lhs,
+ const __normal_iterator<_IteratorF, _ContainerF>& __rhs)
+ _GLIBCXX_NOEXCEPT;
+
+ template<typename _IteratorL, typename _IteratorR, typename _ContainerF>
+ __attribute__((__always_inline__)) _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
+ friend inline bool
+ operator!=(const __normal_iterator<_IteratorL, _ContainerF>& __lhs,
+ const __normal_iterator<_IteratorR, _ContainerF>& __rhs)
+ _GLIBCXX_NOEXCEPT;
+
+ template<typename _IteratorF, typename _ContainerF>
+ __attribute__((__always_inline__)) _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
+ friend inline bool
+ operator!=(const __normal_iterator<_IteratorF, _ContainerF>& __lhs,
+ const __normal_iterator<_IteratorF, _ContainerF>& __rhs)
+ _GLIBCXX_NOEXCEPT;
+
+ // Random access iterator requirements
+ template<typename _IteratorL, typename _IteratorR, typename _ContainerF>
+ __attribute__((__always_inline__)) _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
+ friend inline bool
+ operator<(const __normal_iterator<_IteratorL, _ContainerF>& __lhs,
+ const __normal_iterator<_IteratorR, _ContainerF>& __rhs)
+ _GLIBCXX_NOEXCEPT;
+
+ template<typename _IteratorF, typename _ContainerF>
+ __attribute__((__always_inline__)) _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
+ friend inline bool
+ operator<(const __normal_iterator<_IteratorF, _ContainerF>& __lhs,
+ const __normal_iterator<_IteratorF, _ContainerF>& __rhs)
+ _GLIBCXX_NOEXCEPT;
+
+ template<typename _IteratorL, typename _IteratorR, typename _ContainerF>
+ __attribute__((__always_inline__)) _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
+ friend inline bool
+ operator>(const __normal_iterator<_IteratorL, _ContainerF>& __lhs,
+ const __normal_iterator<_IteratorR, _ContainerF>& __rhs)
+ _GLIBCXX_NOEXCEPT;
+
+ template<typename _IteratorF, typename _ContainerF>
+ __attribute__((__always_inline__)) _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
+ friend inline bool
+ operator>(const __normal_iterator<_IteratorF, _ContainerF>& __lhs,
+ const __normal_iterator<_IteratorF, _ContainerF>& __rhs)
+ _GLIBCXX_NOEXCEPT;
+
+ template<typename _IteratorL, typename _IteratorR, typename _ContainerF>
+ __attribute__((__always_inline__)) _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
+ friend inline bool
+ operator<=(const __normal_iterator<_IteratorL, _ContainerF>& __lhs,
+ const __normal_iterator<_IteratorR, _ContainerF>& __rhs)
+ _GLIBCXX_NOEXCEPT;
+
+ template<typename _IteratorF, typename _ContainerF>
+ __attribute__((__always_inline__)) _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
+ friend inline bool
+ operator<=(const __normal_iterator<_IteratorF, _ContainerF>& __lhs,
+ const __normal_iterator<_IteratorF, _ContainerF>& __rhs)
+ _GLIBCXX_NOEXCEPT;
+
+ template<typename _IteratorL, typename _IteratorR, typename _ContainerF>
+ __attribute__((__always_inline__)) _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
+ friend inline bool
+ operator>=(const __normal_iterator<_IteratorL, _ContainerF>& __lhs,
+ const __normal_iterator<_IteratorR, _ContainerF>& __rhs)
+ _GLIBCXX_NOEXCEPT;
+
+ template<typename _IteratorF, typename _ContainerF>
+ __attribute__((__always_inline__)) _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
+ friend inline bool
+ operator>=(const __normal_iterator<_IteratorF, _ContainerF>& __lhs,
+ const __normal_iterator<_IteratorF, _ContainerF>& __rhs)
+ _GLIBCXX_NOEXCEPT;
+#endif // three-way comparison
+
+ // _GLIBCXX_RESOLVE_LIB_DEFECTS
+ // According to the resolution of DR179 not only the various comparison
+ // operators but also operator- must accept mixed iterator/const_iterator
+ // parameters.
+ template<typename _IteratorL, typename _IteratorR, typename _ContainerF>
+#if __cplusplus >= 201103L
+ // DR 685.
+ friend constexpr auto
+ operator-(const __normal_iterator<_IteratorL, _ContainerF>& __lhs,
+ const __normal_iterator<_IteratorR, _ContainerF>& __rhs) noexcept
+ -> decltype(__lhs.base() - __rhs.base());
+#else
+ friend inline typename __normal_iterator<_IteratorL, _ContainerF>::difference_type
+ operator-(const __normal_iterator<_IteratorL, _ContainerF>& __lhs,
+ const __normal_iterator<_IteratorR, _ContainerF>& __rhs);
+#endif
+
+ template<typename _IteratorF, typename _ContainerF>
+ __attribute__((__always_inline__)) _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
+ friend inline typename __normal_iterator<_IteratorF, _ContainerF>::difference_type
+ operator-(const __normal_iterator<_IteratorF, _ContainerF>& __lhs,
+ const __normal_iterator<_IteratorF, _ContainerF>& __rhs)
+ _GLIBCXX_NOEXCEPT;
+
+ template<typename _IteratorF, typename _ContainerF>
+ __attribute__((__always_inline__)) _GLIBCXX_NODISCARD _GLIBCXX_CONSTEXPR
+ friend inline __normal_iterator<_IteratorF, _ContainerF>
+ operator+(typename __normal_iterator<_IteratorF, _ContainerF>::difference_type
+ __n, const __normal_iterator<_IteratorF, _ContainerF>& __i)
+ _GLIBCXX_NOEXCEPT;
+};
+
// Note: In what follows, the left- and right-hand-side iterators are
// allowed to vary in types (conceptually in cv-qualification) so that
// comparison between cv-qualified and non-cv-qualified iterators be
--
2.47.0