当前位置: 首页>>代码示例>>C++>>正文


C++ as_value::type_of方法代码示例

本文整理汇总了C++中as_value::type_of方法的典型用法代码示例。如果您正苦于以下问题:C++ as_value::type_of方法的具体用法?C++ as_value::type_of怎么用?C++ as_value::type_of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在as_value的用法示例。


在下文中一共展示了as_value::type_of方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: abstract_equality_comparison

	bool as_value::abstract_equality_comparison( const as_value & first, const as_value & second )
	{
		if (first.type_of() == second.type_of())
		{
			if( first.is_undefined() ) return true;
			if( first.is_null() ) return true;

			if( first.is_number() )
			{
				double first_number = first.to_number();
				double second_number = second.to_number();
				if( first_number == get_nan() || second_number == get_nan() )
				{
					return false;
				}

				return first_number == second_number;
			}
			else if( first.is_string() )
			{
				return first.to_tu_string() == second.to_tu_string();
			}
			else if( first.is_bool() )
			{
				return first.to_bool() == second.to_bool();
			}

			//13.Return true if x and y refer to the same object or if they refer to objects joined to each other (see
			//13.1.2). Otherwise, return false.
			// TODO: treat joined object

			return first.to_object() == second.to_object();
		}
		else
		{

			if( first.is_null() && second.is_undefined() ) return true;
			if( second.is_null() && first.is_undefined() ) return true;

			if( ( first.is_number() && second.is_string() ) 
				|| (second.is_number() && first.is_string() ) )
			{
				return first.to_number() == second.to_number();
			}

			if( first.is_bool() || second.is_bool() ) return first.to_number() == second.to_number();

			// TODO:20.If Type(x) is either String or Number and Type(y) is Object,
			//return the result of the comparison x == ToPrimitive(y).
			//21.If Type(x) is Object and Type(y) is either String or Number,
			//return the result of the comparison ToPrimitive(x) == y.

			return false;
		}
	}
开发者ID:Cucurbitace,项目名称:attract,代码行数:55,代码来源:gameswf_value.cpp


注:本文中的as_value::type_of方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。