C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] Modern std::byte stream IO for C++
From: Lyberta (lyberta_at_[hidden])
Date: 2020-03-06 05:03:57


Maciej Cencora:
> Exactly as I said, endianess in your example is a runtime property, while
> in most scenarios it is actually known at compile time.
> It should be something like:
> std::io::default_big_endian_context ctx{stream};
> or
> std::io_default_context<std::endian::big> ctx{stream};
>

I'm pretty sure we can avoid doing explicit NTTP because:

1. Serialization functions should be templates by default.
2. Once compilers implement `std::bit_cast`, everything except system calls in file IO should become constexpr.

I think that templates + constexpr is enough for compiler to see that the developer hard-codes the value of endianness and to
remove dead branches.




STD-PROPOSALS list run by herb.sutter at gmail.com

Standard Proposals Archives on Google Groups