summaryrefslogtreecommitdiff
path: root/wx+/grid.h
diff options
context:
space:
mode:
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