Conditional

Description

This template is used to wrap outputs, which may not be produced under some conditions. The atl::NIL value is returned then.

Consider SegmentSegmentIntersection function. When segments passed to this function do not have any point of intersection, the outIntersectionPoint does not exists, and atl::NIL is returned. Otherwise, correct value of intersection point is calculated, and can be accessed via Get() method (inherited from OptionalBase) of Conditional object.

template< typename T >
class Conditional : public OptionalBase< T >
{
public:
	typedef Conditional< T > MyType;
	typedef OptionalBase< T > MyBase;
	typedef typename MyBase::ValueType ValueType;
	typedef typename MyBase::RefType RefType;
	typedef typename MyBase::ConstValueType ConstValueType;
	typedef typename MyBase::ConstRefType ConstRefType;

	Conditional() : MyBase() { }
	Conditional( const Conditional< ValueType >& other ) : MyBase(other) { }
	Conditional( const Conditional< RefType >& other ) : MyBase(other) { }
	Conditional( const Conditional< ConstValueType >& other ) : MyBase(other) { }
	Conditional( const Conditional< ConstRefType >& other ) : MyBase(other) { }
	Conditional( const NilType& ) : MyBase(NIL) { }
	Conditional( ConstRefType value ) : MyBase(value) { }

	const MyType& operator = ( const Conditional< ValueType >& other );
	const MyType& operator = ( const Conditional< RefType >& other );
	const MyType& operator = ( const Conditional< ConstValueType >& other );
	const MyType& operator = ( const Conditional< ConstRefType >& other );
	const MyType& operator = ( const NilType& );
	const MyType& operator = ( ConstRefType value );

#ifdef HAS_CPP0X

	Conditional( Conditional< ValueType >&& other ) : MyBase( std::move(other) ) { }
	Conditional( ValueType&& value ) : MyBase( std::move(value) ) { }
	const MyType& operator = ( Conditional< ValueType >&& other );
	const MyType& operator = ( ValueType&& value );

#endif

	bool operator == ( const Conditional< ValueType >& other ) const;
	bool operator == ( const Conditional< RefType >& other ) const;
	bool operator == ( const Conditional< ConstValueType >& other ) const;
	bool operator == ( const Conditional< ConstRefType >& other ) const;
	bool operator == ( const NilType& ) const;
	bool operator == ( ConstRefType value ) const;
	
	bool operator != ( const Conditional< ValueType >& other ) const;
	bool operator != ( const Conditional< RefType >& other ) const;
	bool operator != ( const Conditional< ConstValueType >& other ) const;
	bool operator != ( const Conditional< ConstRefType >& other ) const;
	bool operator != ( const NilType& ) const;
	bool operator != ( ConstRefType value ) const;
}