GenericValue: fixup bool constructor
With the new string handling API, the constructor taking a `bool` parameter matches in some unwanted cases, as pointers can be casted to `bool` implicitly. Add a SFINAE helper to this constructor to avoid matching arbitrary pointers. To avoid confusion for the user, this mechanism is hidden from the Doxygen documentation.
This commit is contained in:
parent
ed9cdbc2f7
commit
9b3969d0e1
@ -1991,6 +1991,7 @@ INCLUDE_FILE_PATTERNS =
|
|||||||
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
|
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
|
||||||
|
|
||||||
PREDEFINED = \
|
PREDEFINED = \
|
||||||
|
RAPIDJSON_DOXYGEN_RUNNING \
|
||||||
RAPIDJSON_DISABLEIF_RETURN(cond,returntype)=returntype
|
RAPIDJSON_DISABLEIF_RETURN(cond,returntype)=returntype
|
||||||
|
|
||||||
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
|
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
|
||||||
|
@ -355,8 +355,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
//! Copy constructor is not permitted.
|
//! Copy constructor is not permitted.
|
||||||
GenericValue(const GenericValue& rhs);
|
GenericValue(const GenericValue& rhs);
|
||||||
//! Disabled constructor for arbitrary pointers.
|
|
||||||
template<typename T> explicit GenericValue(T*);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -385,7 +383,18 @@ public:
|
|||||||
GenericValue(const GenericValue<Encoding,SourceAllocator>& rhs, Allocator & allocator);
|
GenericValue(const GenericValue<Encoding,SourceAllocator>& rhs, Allocator & allocator);
|
||||||
|
|
||||||
//! Constructor for boolean value.
|
//! Constructor for boolean value.
|
||||||
explicit GenericValue(bool b) : data_(), flags_(b ? kTrueFlag : kFalseFlag) {}
|
/*! \param b Boolean value
|
||||||
|
\note This constructor is limited to \em real boolean values and rejects
|
||||||
|
implicitly converted types like arbitrary pointers. Use an explicit cast
|
||||||
|
to \c bool, if you want to construct a boolean JSON value in such cases.
|
||||||
|
*/
|
||||||
|
#ifndef RAPIDJSON_DOXYGEN_RUNNING // hide SFINAE from Doxygen
|
||||||
|
template <typename T>
|
||||||
|
explicit GenericValue(T b, RAPIDJSON_ENABLEIF((internal::IsSame<T,bool>)))
|
||||||
|
#else
|
||||||
|
explicit GenericValue(bool b)
|
||||||
|
#endif
|
||||||
|
: data_(), flags_(b ? kTrueFlag : kFalseFlag) {}
|
||||||
|
|
||||||
//! Constructor for int value.
|
//! Constructor for int value.
|
||||||
explicit GenericValue(int i) : data_(), flags_(kNumberIntFlag) {
|
explicit GenericValue(int i) : data_(), flags_(kNumberIntFlag) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user