diff options
author | B Stack <bgstack15@gmail.com> | 2018-10-16 17:33:51 -0400 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2018-10-16 17:33:51 -0400 |
commit | 878a41d3be13da2a654df74f2a35ea8b295c8a13 (patch) | |
tree | 89b2a018482c164bdd8ecac5c76b19a08f420dec /wx+/grid.h | |
parent | Merge branch '10.4' into 'master' (diff) | |
download | FreeFileSync-878a41d3be13da2a654df74f2a35ea8b295c8a13.tar.gz FreeFileSync-878a41d3be13da2a654df74f2a35ea8b295c8a13.tar.bz2 FreeFileSync-878a41d3be13da2a654df74f2a35ea8b295c8a13.zip |
10.5
Diffstat (limited to 'wx+/grid.h')
-rwxr-xr-x | wx+/grid.h | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -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; } |