aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
Diffstat (limited to 'host')
-rw-r--r--host/include/uhd/utils/CMakeLists.txt1
-rw-r--r--host/include/uhd/utils/noncopyable.hpp55
2 files changed, 56 insertions, 0 deletions
diff --git a/host/include/uhd/utils/CMakeLists.txt b/host/include/uhd/utils/CMakeLists.txt
index 7f45df1d3..894a804c4 100644
--- a/host/include/uhd/utils/CMakeLists.txt
+++ b/host/include/uhd/utils/CMakeLists.txt
@@ -20,6 +20,7 @@ UHD_INSTALL(FILES
log_add.hpp
math.hpp
msg_task.hpp
+ noncopyable.hpp
paths.hpp
pimpl.hpp
platform.hpp
diff --git a/host/include/uhd/utils/noncopyable.hpp b/host/include/uhd/utils/noncopyable.hpp
new file mode 100644
index 000000000..0f480f6c3
--- /dev/null
+++ b/host/include/uhd/utils/noncopyable.hpp
@@ -0,0 +1,55 @@
+//
+// Copyright 2019 Ettus Research, a National Instruments Brand
+//
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+
+#ifndef INCLUDED_UHDLIB_UTILS_NONCOPYABLE_HPP
+#define INCLUDED_UHDLIB_UTILS_NONCOPYABLE_HPP
+
+#ifdef UHD_AVOID_BOOST
+
+namespace uhd {
+
+/*! Non-copyable class
+ *
+ * This is a re-implementation of boost::noncopyable using C++11 features.
+ * Deriving a class from this one will disallow it being assigned or copied:
+ *
+ * ~~~~{.cpp}
+ * #include <uhdlib/utils/noncopyable.hpp>
+ *
+ * class C : uhd::noncopyable {};
+ *
+ * C c1;
+ * C c2(c1); // Won't work
+ * C c3;
+ * c3 = c1; // Won't work
+ * ~~~~
+ */
+class noncopyable
+{
+public:
+ noncopyable() = default;
+ ~noncopyable() = default;
+
+ noncopyable(const noncopyable&) = delete;
+ noncopyable& operator=(const noncopyable&) = delete;
+};
+
+} /* namespace uhd */
+
+#else
+
+# if BOOST_VERSION >= 105600
+# include <boost/core/noncopyable.hpp>
+# else
+# include <boost/noncopyable.hpp>
+# endif
+namespace uhd {
+typedef boost::noncopyable noncopyable;
+}
+
+#endif
+
+#endif /* INCLUDED_UHDLIB_UTILS_NONCOPYABLE_HPP */