boostorg / multiprecision

Boost.Multiprecision
Boost Software License 1.0
194 stars 111 forks source link

Feature request: View-type for numbers #558

Open liss-h opened 1 year ago

liss-h commented 1 year ago

Hi there, is there any plan to have a "view" type for numbers? (I.e. something like what std::string_view is to std::string)?

The usecase we had in mind would be a type "views" into the internals of a boost multiprecision number stored in some user defined backend storage, and is primarily used for the purpose of abstracting away the allocator on the backend-frontend interface boundary (like std::basic_string_view<char, char_traits> can do for std::basic_string<char, char_traits, alloc>). I know, that is potentially quite a niche usecase.

So, basically 3 questions:

  1. Like I asked on top: Is there already a plan to implement something like this?
  2. If there isn't any plan: Would you accept a contribution?
  3. If you do accept contributions: Do you foresee any major blockers that would prevent the implementation of that feature?
mborland commented 1 year ago
  1. Like I asked on top: Is there already a plan to implement something like this?

I am not aware of any plan for this feature.

  1. If there isn't any plan: Would you accept a contribution?

Contributions are always welcome.

  1. If you do accept contributions: Do you foresee any major blockers that would prevent the implementation of that feature?

The language standard is C++14, and if you use any boost features (e.g. Boost string_view) make sure that they can be contextually disabled with BOOST_MP_STANDALONE to keep the standalone mode functioning.