Commit 90ade58b authored by Jason Rhinelander's avatar Jason Rhinelander

Remove hack needed for g++-4.8

g++-4.8 isn't supported now by the code (except via patches for
ubuntu-trusty), so removing this other hack that was been around for
g++-4.8 to give all_combinations a much nicer interface.
parent e42ddc78
......@@ -35,24 +35,17 @@ namespace eris {
* combination of parameters. The argument is a new unique list of elements of the input
* set. Despite being in a vector, these values should really be treated as a set. Values
* will be in the same order as encountered in the input iterator.
*
* \tparam T the underlying data type template parameter is required, unfortunately. This shouldn't
* be necessary at all, since it is obtainable from the class of the given iterator, but gcc
* (as of 4.8.1) chokes on that, hence the additional (required) template parameter.
*/
// FIXME: this first `T` template parameter shouldn't be needed (and isn't, if using clang++), but
// g++ needs it, so everything has to deal with it. Try again, eventually, to remove it, changing
// the 'T' types below to 'typename It::value_type'.
template <typename T, typename It>
template <typename It>
typename std::enable_if<std::is_base_of<std::forward_iterator_tag, typename std::iterator_traits<It>::iterator_category>::value>::type
all_combinations(
const It &begin,
const It &end,
std::function<void(const std::vector<T> &)> func
std::function<void(const std::vector<typename It::value_type> &)> func
) {
// Store the current combination being considered
std::vector<T> combination; // Will store the current combination being considered
std::vector<typename It::value_type> combination; // Will store the current combination being considered
// The first combination is always the empty set; call with it:
func(combination);
......
......@@ -34,12 +34,12 @@ int main() {
permute.insert(88);
permute.insert(99);
eris::all_combinations<eris_id_t>(permute.begin(), permute.end(), print_vec);
eris::all_combinations<eris_id_t>(permute.crbegin(), permute.crend(),
eris::all_combinations(permute.begin(), permute.end(), print_vec);
eris::all_combinations(permute.crbegin(), permute.crend(),
[](const std::vector<eris_id_t> &comb) -> void { print_vec(comb); });
std::unordered_set<eris_id_t> pb;
pb.insert(33);
pb.insert(44);
eris::all_combinations<eris_id_t>(pb.cbegin(), pb.cend(), print_vec);
eris::all_combinations(pb.cbegin(), pb.cend(), print_vec);
}
......@@ -130,7 +130,7 @@ bool IncrementalBuyer::oneRound() {
// From everything added into permute, above, we need to build all possible multi-element
// combinations; e.g. if permute = {1,2,3} we have 4 possibilities: {1,2}, {1,3}, {2,3}, {1,2,3}
eris::all_combinations<eris_id_t>(permute.cbegin(), permute.cend(),
eris::all_combinations(permute.cbegin(), permute.cend(),
[&](const std::vector<eris_id_t> &combination) -> void {
int comb_size = combination.size();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment