public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Peter Bergner <bergner@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ibm/heads/gcc-9-branch)] libstdc++: Mark experimental::net::system_context ctor deleted Date: Fri, 4 Sep 2020 19:06:17 +0000 (GMT) [thread overview] Message-ID: <20200904190617.13B013850425@sourceware.org> (raw) https://gcc.gnu.org/g:bdeb48c6d84c7651f180887c66f617aaaf598ac3 commit bdeb48c6d84c7651f180887c66f617aaaf598ac3 Author: Thomas Rodgers <rodgert@appliantology.com> Date: Thu Apr 23 13:42:46 2020 -0700 libstdc++: Mark experimental::net::system_context ctor deleted Backport from mainline. * include/experimental/net/executor (system_context): Mark system_context::system_context() = delete. * testsuite/experimental/net/executor/1.cc: Add new test to check system_context is not default constructible. Diff: --- libstdc++-v3/ChangeLog | 9 ++ libstdc++-v3/include/experimental/executor | 2 +- .../testsuite/experimental/net/executor/1.cc | 100 +++++++++++++++++++++ 3 files changed, 110 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 3f9eb05afc0..9434ab185fe 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,12 @@ +2020-04-23 Thomas Rodgers <rodgert@appliantology.com> + + Backport from mainline + 2020-04-23 Thomas Rodgers <rodgert@appliantology.com> + * include/experimental/net/executor (system_context): Mark + system_context::system_context() = delete. + * testsuite/experimental/net/executor/1.cc: Add new + test to check system_context is not default constructible. + 2020-04-23 Thomas Rodgers <trodgers@redhat.com> Backport from mainline diff --git a/libstdc++-v3/include/experimental/executor b/libstdc++-v3/include/experimental/executor index 15f28de9b9d..9c0c7186234 100644 --- a/libstdc++-v3/include/experimental/executor +++ b/libstdc++-v3/include/experimental/executor @@ -854,7 +854,7 @@ inline namespace v1 // construct / copy / destroy: - system_context() = default; + system_context() = delete; system_context(const system_context&) = delete; system_context& operator=(const system_context&) = delete; diff --git a/libstdc++-v3/testsuite/experimental/net/executor/1.cc b/libstdc++-v3/testsuite/experimental/net/executor/1.cc new file mode 100644 index 00000000000..cd0af4b7737 --- /dev/null +++ b/libstdc++-v3/testsuite/experimental/net/executor/1.cc @@ -0,0 +1,100 @@ +// Copyright (C) 2020 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// <http://www.gnu.org/licenses/>. + +// { dg-do run { target c++14 } } + +#include <experimental/executor> +#include <testsuite_hooks.h> + +namespace net = std::experimental::net; + +void +test01() +{ + net::executor e; + VERIFY( !e ); + VERIFY( e == nullptr ); + VERIFY( nullptr == e ); + VERIFY( e == e ); + VERIFY( e == e ); + net::executor e2; + VERIFY( e == e2 ); + swap(e, e2); + VERIFY( e == e2 ); + e = e2; + VERIFY( e == e2 ); +} + +void +test02() +{ + struct E + { + void on_work_started() const noexcept { } + void on_work_finished() const noexcept { } + net::execution_context& context() const noexcept { return c; } + void dispatch(std::function<void()>, std::allocator<void>) const { } + void post(std::function<void()>, std::allocator<void>) const { } + void defer(std::function<void()>, std::allocator<void>) const { } + + net::execution_context& c; + + bool operator==(const E& rhs) const noexcept + { return &c == &rhs.c; } + }; + + net::execution_context c; + E d{c}; + net::executor e(d); + VERIFY( e == e ); + VERIFY( e != nullptr ); + VERIFY( nullptr != e ); + + VERIFY( &e.context() == &c ); +#if __cpp_rtti + VERIFY( e.target_type() == typeid(E) ); +#endif + VERIFY( *e.target<E>() == d ); + VERIFY( *e.target<const E>() == d ); + VERIFY( *const_cast<const net::executor&>(e).target<E>() == d ); + VERIFY( *const_cast<const net::executor&>(e).target<const E>() == d ); + + net::executor f = e; + VERIFY( f == e ); + e = nullptr; + VERIFY( f != e ); + swap(e, f); + VERIFY( f == nullptr ); + VERIFY( nullptr != e ); + + net::executor g(E{c}); + VERIFY( e == g ); +} + +void +test03() +{ + static_assert( ! std::is_default_constructible<net::system_context>::value, "" ); +} + +int +main() +{ + test01(); + test02(); + test03(); +}
reply other threads:[~2020-09-04 19:06 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200904190617.13B013850425@sourceware.org \ --to=bergner@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).