summaryrefslogtreecommitdiff
path: root/wx+/grid.h
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2018-10-16 17:33:51 -0400
committerB Stack <bgstack15@gmail.com>2018-10-16 17:33:51 -0400
commit878a41d3be13da2a654df74f2a35ea8b295c8a13 (patch)
tree89b2a018482c164bdd8ecac5c76b19a08f420dec /wx+/grid.h
parentMerge branch '10.4' into 'master' (diff)
downloadFreeFileSync-878a41d3be13da2a654df74f2a35ea8b295c8a13.tar.gz
FreeFileSync-878a41d3be13da2a654df74f2a35ea8b295c8a13.tar.bz2
FreeFileSync-878a41d3be13da2a654df74f2a35ea8b295c8a13.zip
10.5
Diffstat (limited to 'wx+/grid.h')
-rwxr-xr-xwx+/grid.h20
1 files changed, 15 insertions, 5 deletions
diff --git a/wx+/grid.h b/wx+/grid.h
index 732a4fcb..ccf7ad64 100755
--- a/wx+/grid.h
+++ b/wx+/grid.h
@@ -9,9 +9,11 @@
#include <memory>
#include <numeric>
+#include <optional>
+#include <set>
#include <vector>
-#include <wx/scrolwin.h>
#include <zen/basic_math.h>
+#include <wx/scrolwin.h>
//a user-friendly, extensible and high-performance grid control
@@ -362,10 +364,18 @@ private:
template <class ColAttrReal>
std::vector<ColAttrReal> makeConsistent(const std::vector<ColAttrReal>& attribs, const std::vector<ColAttrReal>& defaults)
{
- std::vector<ColAttrReal> output = attribs;
- //make sure each type is existing!
- output.insert(output.end(), defaults.begin(), defaults.end());
- removeDuplicates(output, [](const ColAttrReal& lhs, const ColAttrReal& rhs) { return lhs.type < rhs.type; });
+ using ColTypeReal = decltype(ColAttrReal().type);
+ std::vector<ColAttrReal> output;
+
+ std::set<ColTypeReal> usedTypes; //remove duplicates
+ auto appendUnique = [&](const std::vector<ColAttrReal>& attr)
+ {
+ std::copy_if(attr.begin(), attr.end(), std::back_inserter(output),
+ [&](const ColAttrReal& a) { return usedTypes.insert(a.type).second; });
+ };
+ appendUnique(attribs);
+ appendUnique(defaults); //make sure each type is existing!
+
return output;
}
bgstack15