Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

frame_graph's FG_DEPS #340

Closed
Nielsbishere opened this issue May 28, 2019 · 2 comments
Closed

frame_graph's FG_DEPS #340

Nielsbishere opened this issue May 28, 2019 · 2 comments

Comments

@Nielsbishere
Copy link
Contributor

Nielsbishere commented May 28, 2019

Is your request related to a problem? Please describe.
FG_DEPS doesn't allow infinite expansion (only up to 6 dependencies) and requires the end-user to specify number of dependencies; which is redundant if using templates instead.

Describe the solution you'd like

fg_dep<DeferredMainTaskData, RTHybridData>();

where fg_dep:

namespace fg_deps
{
	using type = std::vector<std::reference_wrapper<const std::type_info>>;

	template<typename T, typename ...args>
	struct insert
	{
		static inline void exec(type& deps)
		{
			deps.push_back(typeid(T));
			fg_deps::insert<args...>::exec(deps);
		}
	};

	template<typename T>
	struct insert<T>
	{
		static inline void exec(type& deps)
		{
			deps.push_back(typeid(T));
		}
	};

	template<typename ...args>
	static inline type make() {
		type result;
		insert<args...>::exec(result);
		return result;
	}

}

template<typename ...args>
static const fg_deps::type& fg_dep()
{
	static fg_deps::type deps = fg_deps::make<args...>();
	return deps;
}

Describe alternatives you've considered
Additional context
N.A.

@VZout
Copy link
Contributor

VZout commented May 28, 2019

My solution to this was just:

template<class ...Ts>
std::vector<std::reference_wrapper<const std::type_info>> Deps() {
    return { (typeid(Ts))...};
}

@Nielsbishere
Copy link
Contributor Author

Yeah that's way cleaner, I didn't know this was a way of calling functions with variadic arguments. Only used sizeof...() before; which is different.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants