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

[rand.synopsis] unhelpfully incomplete #2727

Closed
ben-craig opened this issue Mar 3, 2019 · 2 comments
Closed

[rand.synopsis] unhelpfully incomplete #2727

ben-craig opened this issue Mar 3, 2019 · 2 comments

Comments

@ben-craig
Copy link

[rand.req.eng] gives all random engines a non member streaming operator<< and operator>> implementation. These operators are only mentioned in [rand.req.eng], and never again. This is misleading for those that are trying to audit the standard by looking at the various synopsis of the headers and classes.

Please mention the engine operator<< and operator>> overloads in [rand.synopsis].

I care about this because of the editorial strategy in https://wg21.link/P0829 . Items that are not in the synopsis are much harder to annotate.

Wording in [rand.synopsis]:

  // [rand.eng.lcong], class template linear_­congruential_­engine
  template<class UIntType, UIntType a, UIntType c, UIntType m>
    class linear_congruential_engine;

+  template<class charT, class traits, class UIntType, UIntType a, UIntType c, UIntType m>
+    basic_istream<charT, traits>&
+      operator>>(basic_istream<charT, traits>& is, linear_congruential_engine<UIntType, a, c, m>& x);
+  template<class charT, class traits, class UIntType, UIntType a, UIntType c, UIntType m>
+    basic_ostream<charT, traits>&
+      operator<<(basic_ostream<charT, traits>& os, const linear_congruential_engine<UIntType, a, c, m>& x);
+
  // [rand.eng.mers], class template mersenne_­twister_­engine
  template<class UIntType, size_t w, size_t n, size_t m, size_t r,
           UIntType a, size_t u, UIntType d, size_t s,
           UIntType b, size_t t,
           UIntType c, size_t l, UIntType f>
    class mersenne_twister_engine;

+  template<class charT, class traits,
+           class UIntType, size_t w, size_t n, size_t m, size_t r,
+           UIntType a, size_t u, UIntType d, size_t s,
+           UIntType b, size_t t,
+           UIntType c, size_t l, UIntType f>
+    basic_istream<charT, traits>&
+      operator>>(basic_istream<charT, traits>& is,
+                 mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x);
+
+  template<class charT, class traits,
+           class UIntType, size_t w, size_t n, size_t m, size_t r,
+           UIntType a, size_t u, UIntType d, size_t s,
+           UIntType b, size_t t,
+           UIntType c, size_t l, UIntType f>
+    basic_ostream<charT, traits>&
+      operator<<(basic_ostream<charT, traits>& os,
+                 const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x);
+
  // [rand.eng.sub], class template subtract_­with_­carry_­engine
  template<class UIntType, size_t w, size_t s, size_t r>
    class subtract_with_carry_engine;

+  template<class charT, class traits, class UIntType, size_t w, size_t s, size_t r>
+    basic_istream<charT, traits>&
+      operator>>(basic_istream<charT, traits>& is, subtract_with_carry_engine<UIntType, w, s, r>& x);
+  template<class charT, class traits, class UIntType, size_t w, size_t s, size_t r>
+    basic_ostream<charT, traits>&
+      operator<<(basic_ostream<charT, traits>& os, const subtract_with_carry_engine<UIntType, w, s, r>& x);
+
@jwakely
Copy link
Member

jwakely commented Mar 3, 2019

Please mention the engine operator<< and operator>> overloads in [rand.synopsis].

The current formulation allows them to be implemented as invisible friends. If they're declared at namespace scope in the synopsis that won't be allowed (and compile-time performance can only get worse as a result).

I am very strongly opposed to the suggested edit.

@jensmaurer
Copy link
Member

So, this is not a topic that could be addressed editorially, because actually having a declaration at namespace scope changes semantics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants