C++ Logo


Advanced search

Physical Unit Types as NTTP

From: Victor Dyachenko <__vic_at_[hidden]>
Date: Thu, 09 Jan 2020 13:20:37 +0300

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.

Received on 2020-01-09 04:23:11