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

docs(ref): document more of mp_units.core #662

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

JohelEGP
Copy link
Collaborator

@JohelEGP JohelEGP commented Dec 25, 2024

This is still a WIP (continues #628):

TBDs and still missing:

  • TBD: The quantity specification conversion algorithms.
  • TBD: The collapse common unit algorithms.
  • TBD: The dimension symbol formatting functions.
  • TBD: The unit symbol formatting functions.
  • TBD: The semantic requirements on the QuantityCharacterRepresentation concepts.
  • TBD: sudo_cast.
  • P1: Text output.
  • P2: system_reference
  • P1: math.h
  • P1: random.h

@JohelEGP JohelEGP changed the title docs(ref): document math.h docs(ref): document more of mp_units.core Dec 25, 2024
Comment on lines +6323 to +6324
% Should this come before the above, like in the C++ standard?
\rSec4[qty.rand.bern.geo]{Class template \tcode{geometric_distribution}}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the comment.
In the C++ Standard, geometric_distribution comes between
binomial_distribution and negative_binomial_distribution.

Comment on lines +6472 to +6483
\indexlibrarymemberx{extreme_value_distribution}{operator()}
\begin{itemdecl}
template<typename Generator>
Q operator()(Generator& g);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Equivalent to:
\tcode{return Q(base::operator()(g));}
\end{itemdescr}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I get rid of these optimizations?
The requirements should be equivalent.
However, I don't see that Q::unit is required to be mp_units::one.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of our contributors provided this code. I did a short review but never had time to analyze all the generators properly. If you see any issues, please do not hesitate to fix them or create a new Issue with the list of things to do.

Comment on lines +1818 to +1822
\item
Otherwise, no effect.
\begin{note}
UTF-8 text can't be copied to \tcode{CharT} output.
\end{note}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a constraint (that CharT be either char or char8_t).

Comment on lines +1824 to +1834
\item
Otherwise, if \tcode{std::is_same_v<CharT, char>} is \tcode{true}, equivalent to:
\begin{codeblock}
out = std::ranges::copy(txt.portable(), out)
\end{codeblock}
% The following item can be turned into a compile-time error.
\item
Otherwise, no effect.
\begin{note}
Portable text can't be copied to \tcode{CharT} output.
\end{note}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, in this last case,

  • fmt.char_set is character_set::portable, and
  • CharT is char8_t.

Why can you initialize a char8_t from a char literal,
but not write a string of chars to a char8_t stream?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really do not know what the rationale was, but I remember that it was the case in https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0482r6.html#design_compat_core_init.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I think you might be referring me to the language rules here.
I literally meant you, as to why, for example, you choose to do *out++ = '1' above.
This is the same issue I mentioned about the bit_cast in #628.
My understanding is that this '1' will be converted to char8_t like any other integer type,
having the same integer value, which isn't required to represent the same character when its character set isn't ASCII.
Likewise, I might just be crazy and we can leave this to the WG21 reviewers.

Copy link
Owner

@mpusz mpusz Dec 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the language rules I sent you, initializing char8_t from char and vice versa is OK. However, it is not allowed for arrays of characters or pointers to such.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that only for literals?

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

Successfully merging this pull request may close these issues.

2 participants