]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common: add helper for making std::array with computable size
authorPatrick Donnelly <pdonnell@redhat.com>
Wed, 7 Aug 2024 19:42:48 +0000 (15:42 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Thu, 8 Aug 2024 00:52:37 +0000 (20:52 -0400)
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/common/make_array.h [new file with mode: 0644]

diff --git a/src/common/make_array.h b/src/common/make_array.h
new file mode 100644 (file)
index 0000000..9954c86
--- /dev/null
@@ -0,0 +1,24 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2024 IBM, Inc.
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation. See file COPYING.
+ *
+ */
+
+#pragma once
+
+#include <type_traits>
+#include <array>
+
+template<typename CT, typename... Args>
+constexpr auto make_array(Args&&... args)
+{
+  return std::array<CT, sizeof...(Args)>{std::forward<CT>(args)...};
+}