C++ Logo


Advanced search

Subject: Physical Unit Types as NTTP
From: Victor Dyachenko (__vic_at_[hidden])
Date: 2020-01-09 04:20:37


Current requirements in
make it impossible to use abstract physical unit types
(like described in
as an NTTP.

We have such types in stdlib since C++11 - chrono duration

     template<..., auto Timeout>
     class request_response_map
         static constexpr auto timeout = Timeout;

     using std::literals;
     request_response_map<..., 1s> map1;
     request_response_map<..., 500ms> map2;

Currently this doesn't work because std::chrono::duration
has non-public data members (as any other abstract
physical unit type). Why standard layout requirement is
not enough for "structural type"?

Allowing standard layout types instead of types with only
public data members will solve the problem. And I believe
will not be harder to implement in the compilers.

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups