--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAAHOzFA54sANKYRjvNfsLLU-aOzgHyS%2B_fxvSt%2BDPXmDn%2B3gog%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CA%2B4qT32K0yNwc0XMQF8P4woQRrzwpCQ4H%3DVo8n%2B-aNwyEFfROQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAFd1Zwd7UEpPpdrBqAcq9YB3gJZuXSMp4-FKh2-o3iEBGTpabA%40mail.gmail.com.
* Right now we use CHECKs in base::Value to make sure you e.g. can't get a string from a Value that holds an int. For variants the obvious equivalent would be `absl::get<std::string>(my_variant)`, which throws an exception in case std::string is not the currently active type. Since we usually don't compile with exceptions turned on, this would result in program termination as well, correct?
* Should we allow absl::visit as well or limit its usage in some form? IIRC, alexclarke@ had some concerns regarding binary size for the version accepting multiple variants at the same time. See e.g. the discussion on https://crbug.com/1063997.
On Thu, Jul 30, 2020 at 10:51 PM Jan Wilken Dörrie <jdoe...@chromium.org> wrote:* Right now we use CHECKs in base::Value to make sure you e.g. can't get a string from a Value that holds an int. For variants the obvious equivalent would be `absl::get<std::string>(my_variant)`, which throws an exception in case std::string is not the currently active type. Since we usually don't compile with exceptions turned on, this would result in program termination as well, correct?Attempting to throw in Chromium results in termination, yes.Also note absl::holds_alternative<T>(v), which returns whether |v| contains an instance of type T. So you could e.g. writeCHECK(absl::holds_alternative<std::string>(v));return absl::get<std::string>(v);IMO, if you want to enforce correct usage, this is better than "unconditional get() and let it throw if the caller was wrong".
* Should we allow absl::visit as well or limit its usage in some form? IIRC, alexclarke@ had some concerns regarding binary size for the version accepting multiple variants at the same time. See e.g. the discussion on https://crbug.com/1063997.We should definitely allow it in some form, as visit() is important for a lot of variant use cases. Passing multiple variants is certainly rarer than a single one; I don't know the exact binary size impact of doing so. My inclination is always "clamp down as necessary" so I'm naturally inclined toward "allow it
and see if there's really a problem".
PK
--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CALB5StZdKjdzP-13PyJwV3%3D1ODbv4DKDK3iSuqiNyU89Vk%3DnYA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CALB5StY%2B4itorcNbn-j3oUD6nft4w7xC6S96tYg9Z3uOU%2B75yQ%40mail.gmail.com.
Sorry, I was referring to tests for absl's variant. I would prefer if we had some test coverage that lives in Chrome and can't change out too unexpectedly from underneath us, but I might be a bit too cautious here.
--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAAHOzFCnZUadgabCg-nmY3kaUXQNyo8sjMa27as1FzxEcE5ySA%40mail.gmail.com.
Quick question: I assume absl::variant will eventually be replaced with std::variant? Will the testing story be similar for std::variant?