From 69bd89da631ea005c133bb1bf72a8b7b70ae250d Mon Sep 17 00:00:00 2001 From: Thomas Fussell Date: Mon, 1 Aug 2016 18:47:17 -0400 Subject: [PATCH] specialize std::hash for border::side and get rid of border::default --- include/xlnt/styles/border.hpp | 42 +++++++++++++++++++++++----------- source/styles/border.cpp | 5 ---- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/include/xlnt/styles/border.hpp b/include/xlnt/styles/border.hpp index b2f024eb..a7377ade 100644 --- a/include/xlnt/styles/border.hpp +++ b/include/xlnt/styles/border.hpp @@ -36,22 +36,41 @@ namespace xlnt { +enum class XLNT_CLASS border_side +{ + start, + end, + top, + bottom, + diagonal, + vertical, + horizontal +}; + +} // namespace xlnt + +namespace std { + +template<> +struct hash +{ + size_t operator()(const xlnt::border_side &k) const + { + return static_cast(k); + } +}; + +} // namepsace std + +namespace xlnt { + /// /// Describes the border style of a particular cell. /// class XLNT_CLASS border : public hashable { public: - enum class XLNT_CLASS side - { - start, - end, - top, - bottom, - diagonal, - vertical, - horizontal - }; + using side = border_side; class XLNT_CLASS border_property { @@ -72,14 +91,11 @@ public: border_style style_; }; - static border default(); - static const std::unordered_map &get_side_names(); border(); bool has_side(side s) const; - border_property &get_side(side s); const border_property &get_side(side s) const; void set_side(side s, const border_property &prop); diff --git a/source/styles/border.cpp b/source/styles/border.cpp index 1ecbd7e0..85495eb8 100644 --- a/source/styles/border.cpp +++ b/source/styles/border.cpp @@ -69,11 +69,6 @@ void border::border_property::set_style(border_style s) style_ = s; } -border border::default() -{ - return border(); -} - border::border() { sides_ =