Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8253593

Extend ByteSize and WordSize

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Unresolved
    • P4
    • tbd
    • 16
    • hotspot
    • None
    • gc

    Description

      In the review of JDK-8253555 it was suggested that it would be good to extend ByteSize and WordSize with the following:

      ---
      Consider adding
      constexpr ByteSize in_ByteSize(WordSize size) { ... }
      constexpr int in_bytes(WordSize size) { ... }

      Also consider adding the identity conversion
      constexpr ByteSize in_ByteSize(ByteSize size) { return size; }
      which might be useful in generic code?
      ---

      ---
      It would be nice to have a more complete set of operations for ByteSize.
      That way, when writing new code, one doesn't need to remember or look up
      whether the operation you want to use is supported.

      ByteSize operator*(int, ByteSize) -- so multiplicative scaling is commutative

      ByteSize operator/(ByteSize, int) -- division scaling ?

      -- op= variants
      ByteSize& operator+=(ByteSize& x, ByteSize y)
      ByteSize& operator-=(ByteSize& x, ByteSize y)
      ByteSize& operator*=(ByteSize& x, int y)
      ByteSize& operator/=(ByteSize& x, int y)
      ---

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              stefank Stefan Karlsson
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: