Comparison 'a == True' should be 'a is True' if checking for the singleton value True, or 'a' if testing for truthiness(singleton-comparison)因此,将a == True更改为a is True可能会导致不正确的结果(a和True在内存中可能有不同的地址)。
投射的启发,我通过添加几个特性创建了自己的实现:没有运行时检查的版本仍然有一个断言details::can_fully_represent<T, U>, "we shouldn't be using narrow_cast for casts that aren't actually narrowingdetails::static_cast_changes_value<