Ad
Code
Diff
  • #include <algorithm>
    #include <math.h>
    
    template< class T >
    void Swap( T& a, T& b ) 
    {
      std::swap(a, b);
    }
    • #include <algorithm>
    • #include <math.h>
    • template< class T >
    • void Swap( T& a, T& b )
    • {
    • /*
    • a = (reinterpret_cast<long long >(a) + reinterpret_cast<long long >(b));
    • b = (reinterpret_cast<long long >(a) - reinterpret_cast<long long >(b));
    • a = (reinterpret_cast<long long >(a) - reinterpret_cast<long long >(b));
    • */
    • long long plla = *((long long*) &a);
    • long long pllb = *((long long*) &b);
    • plla = plla + pllb ;
    • pllb = plla - pllb ;
    • plla = plla - pllb ;
    • a =*((T*) &plla);
    • b =*((T*) &pllb);
    • std::swap(a, b);
    • }