C++ Logo

std-proposals

Advanced search

Re: [std-proposals] PR: std::allocator<T>::allocate is not freestanding

From: Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>
Date: Sat, 2 Sep 2023 23:09:58 +0100
On Sat, Sep 2, 2023 at 11:00 PM Jens Maurer wrote:
>
> In general, the "freestanding" subset of C++ is a library subset
> to accommodate environments where an operating system might not
> be available, or that are otherwise constrained. For example,
> std::cout will probably never be part of freestanding
> (because e.g. a fridge does not have that).


I'm programming an Arduino microcontroller here right now, and I have
it set up so that I can use 'cout' as follows:

class Flush {} flush;
std::ostream &operator<<(std::ostream &os, Flush const &f) {
Serial.flush(); return os; }
std::ostream &operator<<(std::ostream &os, String const &s) { return
os << s.c_str(); }
extern "C" int _write(int const fd, char const *const ptr, int const len)
{
  (void)fd;
  return Serial.write(ptr, len);
}

Received on 2023-09-02 22:10:10