From 0ab80e0a0ef5b661eb8ec225b7f929ec21221c56 Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Tue, 27 Apr 2021 20:28:25 -0500 Subject: Rename channel.cpp to channels.cpp --- channels/channel.cpp | 28 ---------------------------- channels/channels.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 28 deletions(-) delete mode 100644 channels/channel.cpp create mode 100644 channels/channels.cpp diff --git a/channels/channel.cpp b/channels/channel.cpp deleted file mode 100644 index 8c5b090..0000000 --- a/channels/channel.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include -#include - -class channel { -private: - std::any val; -public: - void write(auto v) { - val = v; - } - auto read() { - while (!val.has_value()); - auto ret = val; - val.reset(); - return ret; - } -}; - -int main() { - channel c; - int x = 1; - c.write(x); - std::cout << std::any_cast(c.read()) << endl; - std::string y = "Hello world"; - c.write(y); - std::cout << std::any_cast(c.read()) << endl; -} diff --git a/channels/channels.cpp b/channels/channels.cpp new file mode 100644 index 0000000..8c5b090 --- /dev/null +++ b/channels/channels.cpp @@ -0,0 +1,28 @@ +#include +#include +#include + +class channel { +private: + std::any val; +public: + void write(auto v) { + val = v; + } + auto read() { + while (!val.has_value()); + auto ret = val; + val.reset(); + return ret; + } +}; + +int main() { + channel c; + int x = 1; + c.write(x); + std::cout << std::any_cast(c.read()) << endl; + std::string y = "Hello world"; + c.write(y); + std::cout << std::any_cast(c.read()) << endl; +} -- cgit v1.2.3-70-g09d2