Commit b9d2332c authored by Xiao Shi's avatar Xiao Shi Committed by Facebook Github Bot

add implicit constructor for `vector<bool>::const_reference` for libcpp

Summary:
Despite the standard, `std::vector<bool>::const_reference` is not `bool` in
libcpp: http://howardhinnant.github.io/onvectorbool.html

Add the implicit ctor so that `f(dynamic)` can be invoked with `f(v[idx])`
where `v` is a `const vector<bool>` under libc++.

Reviewed By: ot

Differential Revision: D8992805

fbshipit-source-id: 0675174c2a247257238bb11b2c7b319653fe92a3
parent bd450a65
......@@ -364,6 +364,10 @@ struct dynamic::NumericTypeHelper<double> {
inline dynamic::dynamic(std::vector<bool>::reference b)
: dynamic(static_cast<bool>(b)) {}
#if defined(_LIBCPP_VERSION)
inline dynamic::dynamic(std::vector<bool>::const_reference b)
: dynamic(static_cast<bool>(b)) {}
#endif
template <
class T,
......
......@@ -177,8 +177,14 @@ struct dynamic : private boost::operators<dynamic> {
* bool. Calling a function f(dynamic) with f(v[idx]) would require a double
* implicit conversion (reference -> bool -> dynamic) which is not allowed,
* hence we explicitly accept the reference proxy.
*
* std::vector<bool>::const_reference is not bool in libcpp:
* http://howardhinnant.github.io/onvectorbool.html
*/
/* implicit */ dynamic(std::vector<bool>::reference val);
#if defined(_LIBCPP_VERSION)
/* implicit */ dynamic(std::vector<bool>::const_reference val);
#endif
/*
* Create a dynamic that is an array of the values from the supplied
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment