From 55b2d00f23be27e65600605177efc6be83deb2b2 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Fri, 7 Aug 2020 13:34:11 +0200 Subject: [PATCH] Add reusable assert template --- include/linuxdeploy/util/assert.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 include/linuxdeploy/util/assert.h diff --git a/include/linuxdeploy/util/assert.h b/include/linuxdeploy/util/assert.h new file mode 100644 index 0000000..e92b7ed --- /dev/null +++ b/include/linuxdeploy/util/assert.h @@ -0,0 +1,17 @@ +#pragma once + +// system headers +#include + +namespace linuxdeploy { + namespace util { + namespace assert { + template + void assert_not_empty(T container) { + if (container.empty()) { + throw std::invalid_argument{"container must not be empty"}; + } + } + } + } +}