The real problem I can see is ... what is
S ... values;
in your class?
That isn't C++, as far I know.
I suppose you can save your values in a std::tuple
std::tuple<S...> value;
so (if you don't want put your s in a std::tuple and compare the tuples, that is simple but isn't funny) the real problem in your code is connected with the use of the tuple.
I propose the following solution in C++17, based on the new fold expression
#include <tuple>
#include <utility>
#include <iostream>
template <typename ... Ts>
struct Signature
{
std::tuple<Ts...> values;
Signature (Ts && ... ts) : values { std::forward<Ts>(ts) ... }
{ }
template <std::size_t ... Is>
bool equalsH (std::index_sequence<Is...> const &, Ts const & ... ts)
{ return ((ts == std::get<Is>(values)) && ... ); }
bool equals (Ts const & ... ts)
{ return equalsH(std::make_index_sequence<sizeof...(Ts)>{}, ts...); }
};
int main ()
{
Signature<int, bool> s { 5, true };
std::cout << s.equals(5, true) << std::endl; // print 1
std::cout << s.equals(5, false) << std::endl; // print 0
std::cout << s.equals(6, false) << std::endl; // print 0
std::cout << s.equals(6, true) << std::endl; // print 0
}
In C++14 you can't use fold expression like in C++17 so you have to modify the helper function (equalH()); I propose the following
template <std::size_t ... Is>
bool equalsH (std::index_sequence<Is...> const &, Ts const & ... ts)
{
using unused = int[];
bool ret { true };
(void)unused { 0, (void(ret &= (ts == std::get<Is>(values))), 0) ... };
return ret;
}
Unfortunately std::make_index_sequence and std::index_sequence are available only starting from C++14, so the preceding example doesn't work in C++11; but create a substitute of std::make_index_sequence and std::index_sequence isn't difficult and, if you want it, you can use the tuple-compare solution
bool equals (Ts && ... ts)
{ return values == std::forward_as_tuple( std::forward<Ts>(ts) ... ); }