Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 6:41:22 PM (8 years ago)
Author:
landauf
Message:

merged remaining commits from cpp11_v2 to cpp11_v3 (for some reason they were not merged in the first attempt)

Location:
code/branches/cpp11_v3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v3

  • code/branches/cpp11_v3/src/libraries/util/Math.h

    r11054 r11068  
    4747#include <cstdlib>
    4848#include <random>
     49#include <type_traits>
    4950
    5051#include <OgreMath.h>
     
    178179        @c Vector3 you get <tt>Vector3(0, 0, 0)</tt>.
    179180    */
    180     template <typename T>
    181     inline T zeroise()
     181    template <typename T> /* for normal classes */ typename std::enable_if<!std::is_enum<T>::value, T>::type
     182    inline /*T*/ zeroise()
    182183    {
    183184        // If you reach this code, you abused zeroise()!
    184185        static_assert(sizeof(T) != sizeof(T), "No template specialization available for T");
     186    }
     187    /// Implementation for enum classes: uses the underlying type to create a zero value.
     188    template <typename T> /* for enum classes */ typename std::enable_if<std::is_enum<T>::value, T>::type
     189    inline /*T*/ zeroise()
     190    {
     191        return static_cast<T>(zeroise<typename std::underlying_type<T>::type>());
    185192    }
    186193
Note: See TracChangeset for help on using the changeset viewer.