Skip to content

feat: customization point to define the components of a QuantityValue #244

@JohelEGP

Description

@JohelEGP

This would be to resolve BobSteagall/wg21#36 in this library.

The idea is to have a customization point similar to quantity_like_traits. It'd be something like quantity_value_traits, with a size for the number of components and an indexed observer for the components.

So given struct vector2d { int x; int y; }, you could specialize it:

struct units::quantity_value_traits<vector2d> {
  static constexpr int size{2};
  template<int I> int get(const vector2d&);
};

Very much like structured bindings. Then, the as-of-yet unnamed quantity_ prefixed wrapper would accept quantity_value_traits::size pairs of template parameter for the dimension/kind and unit of each component in order.

using quantity_vector2d = units::quantity_unnamed<si::dim_length, si::metre, si::dim_acceleration, si::metre_per_second, vector2d>;

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions