Fixed unspecified bool conversion for MSVC CLR for the case when pugixml is compiled as unmanaged and calling code is compiled as managed. Fixes issue 121.
git-svn-id: http://pugixml.googlecode.com/svn/trunk@817 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
parent
1d6db79bd9
commit
8a5144a927
3 changed files with 33 additions and 8 deletions
|
@ -3419,9 +3419,13 @@ namespace pugi
|
|||
{
|
||||
}
|
||||
|
||||
static void unspecified_bool_xml_attribute(xml_attribute***)
|
||||
{
|
||||
}
|
||||
|
||||
xml_attribute::operator xml_attribute::unspecified_bool_type() const
|
||||
{
|
||||
return _attr ? &xml_attribute::_attr : 0;
|
||||
return _attr ? unspecified_bool_xml_attribute : 0;
|
||||
}
|
||||
|
||||
bool xml_attribute::operator!() const
|
||||
|
@ -3663,9 +3667,13 @@ namespace pugi
|
|||
{
|
||||
}
|
||||
|
||||
static void unspecified_bool_xml_node(xml_node***)
|
||||
{
|
||||
}
|
||||
|
||||
xml_node::operator xml_node::unspecified_bool_type() const
|
||||
{
|
||||
return _root ? &xml_node::_root : 0;
|
||||
return _root ? unspecified_bool_xml_node : 0;
|
||||
}
|
||||
|
||||
bool xml_node::operator!() const
|
||||
|
@ -9160,9 +9168,13 @@ namespace pugi
|
|||
return _attribute ? _node : _node.parent();
|
||||
}
|
||||
|
||||
static void unspecified_bool_xpath_node(xpath_node***)
|
||||
{
|
||||
}
|
||||
|
||||
xpath_node::operator xpath_node::unspecified_bool_type() const
|
||||
{
|
||||
return (_node || _attribute) ? &xpath_node::_node : 0;
|
||||
return (_node || _attribute) ? unspecified_bool_xpath_node : 0;
|
||||
}
|
||||
|
||||
bool xpath_node::operator!() const
|
||||
|
@ -9637,9 +9649,13 @@ namespace pugi
|
|||
return _result;
|
||||
}
|
||||
|
||||
static void unspecified_bool_xpath_query(xpath_query***)
|
||||
{
|
||||
}
|
||||
|
||||
xpath_query::operator xpath_query::unspecified_bool_type() const
|
||||
{
|
||||
return _impl ? &xpath_query::_impl : 0;
|
||||
return _impl ? unspecified_bool_xpath_query : 0;
|
||||
}
|
||||
|
||||
bool xpath_query::operator!() const
|
||||
|
|
|
@ -273,7 +273,7 @@ namespace pugi
|
|||
private:
|
||||
xml_attribute_struct* _attr;
|
||||
|
||||
typedef xml_attribute_struct* xml_attribute::*unspecified_bool_type;
|
||||
typedef void (*unspecified_bool_type)(xml_attribute***);
|
||||
|
||||
public:
|
||||
// Default constructor. Constructs an empty attribute.
|
||||
|
@ -355,7 +355,7 @@ namespace pugi
|
|||
protected:
|
||||
xml_node_struct* _root;
|
||||
|
||||
typedef xml_node_struct* xml_node::*unspecified_bool_type;
|
||||
typedef void (*unspecified_bool_type)(xml_node***);
|
||||
|
||||
public:
|
||||
// Default constructor. Constructs an empty node.
|
||||
|
@ -899,7 +899,7 @@ namespace pugi
|
|||
void* _impl;
|
||||
xpath_parse_result _result;
|
||||
|
||||
typedef void* xpath_query::*unspecified_bool_type;
|
||||
typedef void (*unspecified_bool_type)(xpath_query***);
|
||||
|
||||
// Non-copyable semantics
|
||||
xpath_query(const xpath_query&);
|
||||
|
@ -977,7 +977,7 @@ namespace pugi
|
|||
xml_node _node;
|
||||
xml_attribute _attribute;
|
||||
|
||||
typedef xml_node xpath_node::*unspecified_bool_type;
|
||||
typedef void (*unspecified_bool_type)(xpath_node***);
|
||||
|
||||
public:
|
||||
// Default constructor; constructs empty XPath node
|
||||
|
|
|
@ -13,8 +13,17 @@ template <typename T> static void generic_bool_ops_test(const T& obj)
|
|||
CHECK(obj);
|
||||
CHECK(!!obj);
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4800) // forcing value to bool 'true' or 'false' (performance warning) - we really want to just cast to bool instead of !!
|
||||
#endif
|
||||
|
||||
bool b1 = null, b2 = obj;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
CHECK(!b1);
|
||||
CHECK(b2);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue