- Timestamp:
- Sep 9, 2008, 10:25:33 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core3/src/util/Convert.h
r1753 r1754 384 384 return convert(output, input, ImplicitPossible<probe>()); 385 385 } 386 387 // template that is used when no explicit template specialisation is available 388 // try explicitConversion() function next. 389 template <class ToType, class FromType> 390 struct ConverterExplicit 391 { 392 static bool convert(ToType* output, const FromType& input) 393 { 394 // check for explicit conversion via function overloading 395 const bool probe = ExplicitConversion<FromType, ToType>::exists; 396 // why conversion:: ? --> below is a 'using' directive, so this template usually 397 // gets instantiated in global namespace 398 return conversion::convert(output, input, ExplicitPossible<probe>()); 399 } 400 }; 401 } 386 } 387 388 // We usually don't have a namespace in util/ but it would still be desirable to lock 389 // everything internal away in namespace conversion. 390 // However this template can be specialised everywhere. 391 392 // Template that is used when no explicit template specialisation is available 393 // try explicitConversion() function next. 394 template <class ToType, class FromType> 395 struct ConverterExplicit 396 { 397 static bool convert(ToType* output, const FromType& input) 398 { 399 // check for explicit conversion via function overloading 400 const bool probe = ExplicitConversion<FromType, ToType>::exists; 401 return conversion::convert(output, input, conversion::ExplicitPossible<probe>()); 402 } 403 }; 402 404 403 405 … … 405 407 // Public Functions // 406 408 ////////////////////// 407 408 // We usually don't have a namespace in util/ but it would still be desirable to lock409 // everything internal away in namespace conversion.410 using conversion::ConverterExplicit;411 409 412 410 /** … … 456 454 inline ToType getConvertedValue(const FromType& input, const ToType& fallback) 457 455 { 458 ToType output = fallback;456 ToType output; 459 457 ConvertValue(&output, input, fallback); 460 458 return output; … … 475 473 inline ToType conversion_cast(const FromType& input, const ToType& fallback) 476 474 { 477 ToType output = fallback;475 ToType output; 478 476 ConvertValue(&output, input, fallback); 479 477 return output;
Note: See TracChangeset
for help on using the changeset viewer.