summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-04-22 10:57:39 +0900
committerTomaž Vajngerl <quikee@gmail.com>2019-04-22 05:51:35 +0200
commit60de1cb01986ff6c9aba58dc05dec6b3dc2402d4 (patch)
treee720f4709b235404e85bf39c5ef95bcc006725d6 /include
parentbb6906b66d7ceac8465b43d7e2b1f05976d43600 (diff)
Replace compile time test with a static_assert
There is no need to check this in a test when we can do it directly in the header. static_assert will complain when compiling something that uses the header file instead of waiting that it finds a piece of code, where it is actually needed. The purpose of the test was the same (fail early). The main problem was that Color can be created and converted to sal_uInt32 string completely in compile time, so it can be used for "case" in a "switch" statement, which requires that in "case" it uses a constant. Normally this isn't possible unless we resolve and convert a Color to sal_uInt32 in compile time. This use-case is used somewhere in the code, but it takes a lot of (re)compiling to get to that piece of code, where it would eventually fail. Change-Id: I1f1f9b77c19a0e61f78ce703b380d98a569da833 Reviewed-on: https://gerrit.libreoffice.org/71060 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'include')
-rw-r--r--include/tools/color.hxx5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/tools/color.hxx b/include/tools/color.hxx
index 25032c5d29b9..9643f4028dc9 100644
--- a/include/tools/color.hxx
+++ b/include/tools/color.hxx
@@ -243,6 +243,11 @@ namespace com { namespace sun { namespace star { namespace uno {
}
} } } }
+// Test compile time conversion of Color to sal_uInt32
+
+static_assert (sal_uInt32(Color(0x00, 0x12, 0x34, 0x56)) == 0x00123456);
+static_assert (sal_uInt32(Color(0x12, 0x34, 0x56)) == 0x00123456);
+
// Color types
constexpr ::Color COL_BLACK ( 0x00, 0x00, 0x00 );