Skip to content
Snippets Groups Projects
  1. May 05, 2021
  2. Apr 30, 2021
  3. Apr 09, 2021
  4. Mar 31, 2021
  5. Mar 26, 2021
  6. Mar 24, 2021
  7. Mar 12, 2021
  8. Jan 31, 2021
  9. Dec 21, 2020
  10. Dec 19, 2020
  11. Dec 18, 2020
  12. Oct 02, 2020
  13. Sep 28, 2020
  14. Apr 23, 2020
  15. Mar 16, 2020
  16. Feb 22, 2020
  17. Feb 20, 2020
  18. Feb 16, 2020
  19. Jan 26, 2020
  20. Jan 08, 2020
  21. Dec 19, 2019
    • Steffen Müthing's avatar
      [tests] Add a test for GeometryType::Id · 04302751
      Steffen Müthing authored and Christoph Grüninger's avatar Christoph Grüninger committed
      04302751
    • Steffen Müthing's avatar
      [GeometryType] Add an integral GeometryType::Id type for use as a template parameter · 95163647
      Steffen Müthing authored and Christoph Grüninger's avatar Christoph Grüninger committed
      While GeometryType is constexpr and can thus be used in a lot of compile time contexts, C++ does not
      allow us to declare a template parameter of type GeometryType, as the standard only allows data
      types that directly map to a built-in integral type for this purpose.
      
      On the other hand, GeometryType itself is just a simple 64 bit struct that stores a few integral
      values, so we can easily map it to an integral type.
      
      This patch does just that by adding an opaque nested type GeometryType::Id that is implemented as a
      scoped enum as well as implicit conversions between GeometryType and GeometryType::Id. By using a
      scoped enum, we clearly tag the type as something which is not a normal number, because C++ requires
      explicit conversion between scoped enums and other integral types.
      
      The storage layout of the id is chosen identical to that of GeometryType, making conversion between
      the two almost free.
      
      When writing a template with a GeometryType parameter, just use the id instead and convert it back
      into a GeometryType inside the template:
      
      template<GeometryType::Id gt_>
      class Foo
      {
        static constexpr GeometryType gt = gt_;
      };
      95163647
Loading