Fixed Sequence Generator for IntGen
This commit is contained in:
parent
bdea6c92b3
commit
ff785188f9
@ -1000,9 +1000,9 @@ public:
|
||||
std::make_shared<cIntGenReplaceRandomly<6>> (a_Seed + 101, bgIce, bgTemperate, 150,
|
||||
std::make_shared<cIntGenAddIslands <6>> (a_Seed + 2000, 200,
|
||||
std::make_shared<cIntGenSetRandomly <6>> (a_Seed + 9, 50, bgOcean,
|
||||
std::make_shared<cIntGenZoom <6>> (a_Seed + 10,
|
||||
std::make_shared<cIntGenLandOcean <5>> (a_Seed + 100, 30
|
||||
)))))))))))))))))))))))))))))));
|
||||
std::make_shared<cIntGenLandOcean <5>> (a_Seed + 100, 30)
|
||||
>> MakeIntGen<cIntGenZoom <6>> (a_Seed + 10)
|
||||
)))))))))))))))))))))))))))));
|
||||
|
||||
m_Gen =
|
||||
std::make_shared<cIntGenSmooth <16>>(a_Seed,
|
||||
|
@ -70,15 +70,20 @@ public:
|
||||
|
||||
};
|
||||
|
||||
template<size_t size, class... Args>
|
||||
struct PackToInt
|
||||
{
|
||||
enum
|
||||
{
|
||||
value = size - sizeof...(Args),
|
||||
};
|
||||
// Code adapted from http://stackoverflow.com/questions/7858817/unpacking-a-tuple-to-call-a-matching-function-pointer
|
||||
|
||||
template<int ...>
|
||||
struct seq { };
|
||||
|
||||
template<int N, int ...S>
|
||||
struct gens : gens<N-1, N-1, S...> { };
|
||||
|
||||
template<int ...S>
|
||||
struct gens<0, S...> {
|
||||
typedef seq<S...> type;
|
||||
};
|
||||
|
||||
|
||||
template<class Gen, class... Args>
|
||||
class cIntGenFactory
|
||||
{
|
||||
@ -95,12 +100,19 @@ public:
|
||||
template <class LhsGen>
|
||||
std::shared_ptr<Gen> construct(LhsGen&& lhs)
|
||||
{
|
||||
return std::make_shared<Gen>(std::get<PackToInt<sizeof...(Args), Args>::value>(m_args)..., std::forward<LhsGen>(lhs));
|
||||
return construct_impl<LhsGen>(std::forward<LhsGen>(lhs), typename gens<sizeof...(Args)>::type());
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
std::tuple<Args...> m_args;
|
||||
|
||||
template <class LhsGen, int... S>
|
||||
std::shared_ptr<Gen> construct_impl(LhsGen&& lhs, seq<S...>)
|
||||
{
|
||||
return std::make_shared<Gen>(std::get<S>(m_args)..., std::forward<LhsGen>(lhs));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template<class T, class RhsGen, class... Args>
|
||||
|
Loading…
Reference in New Issue
Block a user