n/b/runtime: forward child constructor args

This commit is contained in:
Danny Robson 2015-07-28 17:52:21 +10:00
parent 573e44bf6f
commit 8e92bd977b

View File

@ -51,7 +51,8 @@ namespace util { namespace noise { namespace basis {
template <typename B> template <typename B>
struct child : public base { struct child : public base {
child (seed_t _seed): data (_seed) { } template <typename ...Args>
child (seed_t _seed, Args&& ...args): data (_seed, std::forward<Args> (args)...) { }
virtual T operator() (util::point<2,T> p) const override { return data (p); } virtual T operator() (util::point<2,T> p) const override { return data (p); }
virtual range<T> bounds (void) const override { return data.bounds (); } virtual range<T> bounds (void) const override { return data.bounds (); }
virtual seed_t seed (void) const override { return data.seed (); } virtual seed_t seed (void) const override { return data.seed (); }
@ -64,14 +65,14 @@ namespace util { namespace noise { namespace basis {
std::unique_ptr<base> m_child; std::unique_ptr<base> m_child;
public: public:
template <typename B> template <typename B, typename ...Args>
void void
reset (seed_t _seed) reset (seed_t _seed, Args&& ...args)
{ {
using basis_t = B; using basis_t = B;
using child_t = child<basis_t>; using child_t = child<basis_t>;
m_child.reset (new child_t (_seed)); m_child.reset (new child_t (_seed, std::forward<Args> (args)...));
} }
}; };
} } } } } }