checked_cast should support enum sources |
|||
Issue descriptionhttps://chromium-review.googlesource.com/c/602866/1..2/base/cbor/cbor_writer.cc#75 says that a checked_cast<uint8_t>(some_enum) fails to compile with 'no matching function for call to "IsValueInRangeForNumericTypes" '. You should be able to use http://en.cppreference.com/w/cpp/types/underlying_type to map enums to their integer representation type.
,
Aug 14 2017
Sorry for not reading before making suggestions. Kim, can you paste the exact error message here?
,
Aug 14 2017
I wrote a small test and it turns out that the implementation needs some more explicit casts. I'll have a small CL up for review today.
,
Aug 14 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/4d93ee3a4e6940994e72a60ee924db9c94633b8d commit 4d93ee3a4e6940994e72a60ee924db9c94633b8d Author: Justin Schuh <jschuh@chromium.org> Date: Mon Aug 14 20:06:28 2017 Support enum in base/numerics cast templates This fixes checked_cast<>, saturated_cast<>, and strict_cast<> so they properly support enum source types. Bug: 754884 Change-Id: I759fb42d08447c99cc19bd1b913956539d37d706 Reviewed-on: https://chromium-review.googlesource.com/613685 Commit-Queue: Justin Schuh <jschuh@chromium.org> Commit-Queue: Jeffrey Yasskin <jyasskin@chromium.org> Reviewed-by: Jeffrey Yasskin <jyasskin@chromium.org> Cr-Commit-Position: refs/heads/master@{#494153} [modify] https://crrev.com/4d93ee3a4e6940994e72a60ee924db9c94633b8d/base/numerics/safe_conversions.h [modify] https://crrev.com/4d93ee3a4e6940994e72a60ee924db9c94633b8d/base/safe_numerics_unittest.cc
,
Aug 15 2017
|
|||
►
Sign in to add a comment |
|||
Comment 1 by jsc...@chromium.org
, Aug 14 2017