dns_util: Make DohUpgradeEntry non-const when used with std::vector<>
This fixes the build with libstdc++ (with most other standard libraries other than libc++, in fact) after commit f93a48e3 ("Allow upgrade to DoH during automatic mode"): ../../../../../../usr/bin/../lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/bits/stl_vector.h:351:7: error: static_assert failed due to requirement 'is_same<typename remove_cv<const DohUpgradeEntry>::type, const DohUpgradeEntry>::value' "std::vector must have a non-const, non-volatile value_type" static_assert(is_same<typename remove_cv<_Tp>::type, _Tp>::value, ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../base/no_destructor.h:77:28: note: in instantiation of template class 'std::vector<const net::(anonymous namespace)::DohUpgradeEntry, std::allocator<const net::(anonymous namespace)::DohUpgradeEntry> >' requested here alignas(T) char storage_[sizeof(T)]; ^ ../../net/dns/dns_util.cc:147:7: note: in instantiation of template class 'base::NoDestructor<std::vector<const net::(anonymous namespace)::DohUpgradeEntry, std::allocator<const net::(anonymous namespace)::DohUpgradeEntry> > >' requested here upgradable_servers({ ^ ../../net/dns/dns_util.cc:230:36: error: invalid range expression of type 'const std::vector<const net::(anonymous namespace)::DohUpgradeEntry, std::allocator<const net::(anonymous namespace)::DohUpgradeEntry> >'; no viable 'begin' function available for (const auto& upgrade_entry : upgradable_servers) { ^ ~~~~~~~~~~~~~~~~~~ The C++ standard forbids containers of const elements. Callers of GetDohUpgradeList() use it in a safe way anyway, and most of DohUpgradeEntry's members are const. Bug: 957519 Change-Id: I826a51823edb1184c0fae27105101e2894efe568 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1805636 Auto-Submit: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com> Commit-Queue: Eric Orth <ericorth@chromium.org> Reviewed-by:Eric Orth <ericorth@chromium.org> Cr-Commit-Position: refs/heads/master@{#696834}
Showing
Please register or sign in to comment