29 #ifndef THOR_DISTRIBUTION_HPP
30 #define THOR_DISTRIBUTION_HPP
32 #include <Aurora/Meta/Templates.hpp>
35 #include <type_traits>
51 explicit Constant(T value)
65 template <
typename Fn,
typename T>
66 struct IsCompatibleFunction
69 static const bool value = !std::is_convertible<Fn, T>::value;
72 template <
typename U,
typename T>
73 struct IsCompatibleFunction<Distribution<U>, T>
76 static const bool value = std::is_convertible<U, T>::value;
105 typedef std::function<T()> FactoryFn;
113 template <
typename U>
115 AURORA_ENABLE_IF(std::is_convertible<U, T>::value))
116 : mFactory(detail::Constant<T>(constant))
123 template <
typename Fn>
125 AURORA_ENABLE_IF(detail::IsCompatibleFunction<Fn, T>::value))
148 #endif // THOR_DISTRIBUTION_HPP
Distribution(Fn function)
Construct from distribution function.
Definition: Distribution.hpp:124
Class holding a rule to create values with predefined properties.
Definition: Distribution.hpp:42
T operator()() const
Returns a value according to the distribution.
Definition: Distribution.hpp:132
Definition: AnimationMap.hpp:42
Distribution(U constant)
Construct from constant.
Definition: Distribution.hpp:114