C++ Logo


Advanced search

Subject: a trait for contextual convertible to bool?
From: Peter Sommerlad (C++) (peter.cpp_at_[hidden])
Date: 2021-01-18 03:25:14


while trying to implement a better Bool than bool (no implicit
artithmetic, no implicit conversion from arithmetic types) I figured
that there is no trait that models contextual convertibility to bool,
i.e., std::istream& is contextual convertible to bool, but
std::is_convertible<std::istream&,bool> is false_type as well as
std::convertible_to<std::istream&,bool> fails.

Do other feel the need to have such a trait modelling contextual
conversion to bool, or is there a trait that would allow that?

I implemented my own that provides explicit conversion to bool from
class types and pointers, which is what I want to support for my Bool type.



Peter Sommerlad
Better Software: Consulting, Training, Reviews
Modern, Safe & Agile C++
+41 79 432 23 32

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups