Skip to content

Instantly share code, notes, and snippets.

@masfj
Created February 5, 2018 15:04
Show Gist options
  • Save masfj/894c587f82cb5639452ffe1a5d62b609 to your computer and use it in GitHub Desktop.
Save masfj/894c587f82cb5639452ffe1a5d62b609 to your computer and use it in GitHub Desktop.
#include <type_traits>
#include <initializer_list>
#include <iostream>
class enable_class
{
public:
template <typename ... Types, typename std::enable_if_t<sizeof...(Types) == 2, std::nullptr_t> = nullptr>
enable_class(Types... args)
{
using swallow = std::initializer_list<int>;
(void)swallow{(void(this->initialize(args)), 0)...};
}
private:
void
initialize(int a)
{
std::cout << a << std::endl;
}
};
int
main(void)
{
enable_class e(1, 2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment