From d319b3e116ee1203d964bbba57af1fb1a3e50a38 Mon Sep 17 00:00:00 2001
From: Bhuvan Bezawada <bhuvan_777@outlook.com>
Date: Mon, 25 Jun 2018 10:34:18 +0100
Subject: [PATCH] Created a free function to act as a helper

re #22553
The free function reduces code duplication and is slightly
cleaner to use.
---
 .../Kernel/inc/MantidKernel/ContainerDtype.h  | 68 +++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100644 Framework/Kernel/inc/MantidKernel/ContainerDtype.h

diff --git a/Framework/Kernel/inc/MantidKernel/ContainerDtype.h b/Framework/Kernel/inc/MantidKernel/ContainerDtype.h
new file mode 100644
index 00000000000..7ab86706152
--- /dev/null
+++ b/Framework/Kernel/inc/MantidKernel/ContainerDtype.h
@@ -0,0 +1,68 @@
+#ifndef MANTID_KERNEL_CONTAINERDTYPE_H_
+#define MANTID_KERNEL_CONTAINERDTYPE_H_
+
+#include <string>
+#include <vector>
+#include <type_traits>
+
+#include <boost/python/class.hpp>
+#include <boost/python/implicit.hpp>
+#include <boost/python/init.hpp>
+#include <boost/python/make_function.hpp>
+#include <boost/python/register_ptr_to_python.hpp>
+#include <boost/python/return_value_policy.hpp>
+
+/**
+    ContainerDtype Header File
+
+    A helper free function to allow identification of data type being used by providing a
+    numpy friendly string.
+
+    @author Lamar Moore STFC, Bhuvan Bezawada STFC
+    @date 21/06/2018
+
+    Copyright &copy; 2018 ISIS Rutherford Appleton Laboratory, NScD Oak
+    Ridge National Laboratory & European Spallation Source
+
+    This file is part of Mantid.
+
+    Mantid is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 3 of the License, or
+    (at your option) any later version.
+
+    Mantid is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+    File change history is stored at: <https://github.com/mantidproject/mantid>.
+    Code Documentation is available at: <http://doxygen.mantidproject.org>
+*/
+namespace dtypeHelper {
+
+template <template<class> typename Container, typename HeldType>
+std::string dtype(Container<HeldType> &self) {
+  if (std::is_same<HeldType, bool>::value) {
+    return "b";
+  }
+  else if (std::is_integral<HeldType>::value) {
+    return "i";
+  }
+  else if (std::is_floating_point<HeldType>::value) {
+    return "d";
+  }
+  else if (std::is_same<HeldType, std::string>::value) {
+    return "s";
+  }
+  else {
+    return "obj";
+  }
+}
+
+}
+
+#endif /*MANTID_KERNEL_CONTAINERDTYPE_H_*/
-- 
GitLab