Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A Question about the implementation of algorithm factory #53

Open
KenSporger opened this issue Apr 28, 2021 · 0 comments
Open

A Question about the implementation of algorithm factory #53

KenSporger opened this issue Apr 28, 2021 · 0 comments

Comments

@KenSporger
Copy link

I am very interested in the implementation of the algorithm factory in this framework.It's a wonderfull idea to use templates.Now, I have a doubt about the function Register in class AlgorithmRegister(as you see below),

template <int... Is>
  void Register(std::string algorithm_name, int_sequence<Is...>) {
    auto function = std::bind(&AlgorithmRegister<AlgorithmBase, Algorithm, Args...>::create,
                              std::placeholder_template<Is>{}...);
    AlgorithmFactory<AlgorithmBase, Args...>::Register(algorithm_name, function);
  }

Instead of passing the function create directly, it uses bind to wrap it. Such practice leads to a dependency on int_sequence and placeholder_template, making the code complicated. So I rewrite it as follow:

void Register(std::string algorithm_name) {
    AlgorithmFactory<AlgorithmBase, Args...>::Register(algorithm_name, &AlgorithmRegister<AlgorithmBase, Algorithm, Args...>::create);
  }

Would it be better choice?How did the engineer consider it at that time?

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

No branches or pull requests

1 participant