public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rs2740 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/101263] non-propagating-cache::emplace-deref missing constexpr
Date: Thu, 14 Oct 2021 15:43:15 +0000 [thread overview]
Message-ID: <bug-101263-4-u5QVDJRTeh@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101263-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101263
TC <rs2740 at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rs2740 at gmail dot com
--- Comment #7 from TC <rs2740 at gmail dot com> ---
(In reply to Barry Revzin from comment #6)
> The "real" answer is allowing constexpr placement new, but that obviously
> doesn't help you right now.
>
> But I think the helpful answer is that you can add a constructor to your
> storage like storage(init_from_invoke_t, Args&&... args) that initializes
> the underlying value from invoke((Args&&)args...), and then
> construct_at(&storage, init_from_invoke, [&]() -> decltype(auto) { return
> *i; }).
>
> Something like that?
Yes. Something at that level of generality will be needed for the new
optional::transform, so it seems the better approach.
In my proof-of-concept implementation (which didn't have that concern), I used
something tailored to this specific case, along the lines of
struct __deref_tag {};
template<class _Tp>
struct __cache_wrapper {
template<class _Iter>
constexpr __cache_wrapper(__deref_tag, const _Iter& __i)
: __t(*__i) {}
_Tp __t;
};
and then stored a __non_propagating_cache<__cache_wrapper<range_value_t<...>>>
__cache, so that emplace-deref(i) is __cache.emplace(__deref_tag{}, i);
next prev parent reply other threads:[~2021-10-14 15:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-29 17:23 [Bug libstdc++/101263] New: " hewillk at gmail dot com
2021-07-13 17:45 ` [Bug libstdc++/101263] " ppalka at gcc dot gnu.org
2021-09-08 7:42 ` rguenth at gcc dot gnu.org
2021-09-08 10:30 ` redi at gcc dot gnu.org
2021-10-14 8:09 ` redi at gcc dot gnu.org
2021-10-14 15:22 ` ppalka at gcc dot gnu.org
2021-10-14 15:35 ` barry.revzin at gmail dot com
2021-10-14 15:43 ` rs2740 at gmail dot com [this message]
2021-10-15 17:27 ` cvs-commit at gcc dot gnu.org
2021-10-15 17:31 ` redi at gcc dot gnu.org
2021-11-24 12:22 ` redi at gcc dot gnu.org
2022-04-21 7:49 ` rguenth at gcc dot gnu.org
2022-04-21 9:18 ` redi at gcc dot gnu.org
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=bug-101263-4-u5QVDJRTeh@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@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: link
Be 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).