mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-19 17:05:44 +01:00
Core/Misc: VS 2013 build fix - horrible hack.
This commit is contained in:
@@ -81,7 +81,8 @@ namespace Trinity
|
||||
template <class C>
|
||||
typename C::const_iterator SelectRandomWeightedContainerElement(C const& container, std::vector<double> weights)
|
||||
{
|
||||
std::discrete_distribution<uint32> dd(weights.begin(), weights.end());
|
||||
Trinity::discrete_distribution_param<uint32> ddParam(weights.begin(), weights.end());
|
||||
std::discrete_distribution<uint32> dd(ddParam);
|
||||
typename C::const_iterator it = container.begin();
|
||||
std::advance(it, dd(SFMTEngine::Instance()));
|
||||
return it;
|
||||
|
||||
@@ -69,4 +69,26 @@ public:
|
||||
static SFMTEngine& Instance();
|
||||
};
|
||||
|
||||
// Ugly, horrible, i don't even..., hack for VS2013 to work around missing discrete_distribution(iterator, iterator) constructor
|
||||
namespace Trinity
|
||||
{
|
||||
#if COMPILER == COMPILER_MICROSOFT && _MSC_VER <= 1800
|
||||
template<typename T>
|
||||
struct discrete_distribution_param : public std::discrete_distribution<T>::param_type
|
||||
{
|
||||
typedef typename std::discrete_distribution<T>::param_type base;
|
||||
|
||||
template<typename InIt>
|
||||
discrete_distribution_param(InIt begin, InIt end) : base(_Noinit())
|
||||
{
|
||||
this->_Pvec.assign(begin, end);
|
||||
this->_Init();
|
||||
}
|
||||
};
|
||||
#else
|
||||
template<typename T>
|
||||
using discrete_distribution_param = typename std::discrete_distribution<T>::param_type;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // Random_h__
|
||||
|
||||
Reference in New Issue
Block a user