On Thu, Feb 20, 2020 at 19:22 Matt Hurd via Std-Proposals <std-proposals@lists.isocpp.org> wrote:
using my_typedifferent_int_t = int64_t is a little disappointing. No type safety by design which is excellent mostly.

How about:

using new qty_t = int64_t; 
using new px_t = int64_t;
I assume this is similar to rust’s

#[repr(transparent)]
struct qty_t(i64); // i64 = int64_t.

This doesn’t really communicate that intent, imo. 
For integers, we really can do something similar in one line with:
enum class qty_t : int64_t {};
While we are technically out of luck for other types, a wrapping aggregate struct isn’t that horrible (though potentially with an attribute that hints it wants the abi of the wrapped field).

auto bid = qty_t{100};

auto ask = px_t{200};

auto err0 = bid + ask;  // does not compute


& extensions without inheritance for reuse?


template<typename T>

struct bah_humbug_vector2 : new std::vector<T>{


  constexpr auto ssize() const noexcept -> std::make_signed_t<decltype(size())>{

    assert( size() <= std::numeric_limits<size_type>::max );

    return static_cast<std::make_signed_t<decltype(size())>>(size());

  }

};


It would simplify a lot of my life and bring some facilities to C++ other languages support.


< $0.02


--Matt.





--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals