diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h
index 866d667c4..62ee5ebd6 100644
--- a/include/libcamera/controls.h
+++ b/include/libcamera/controls.h
@@ -259,6 +259,25 @@ public:
 	void reserve(ControlType type, bool isArray = false,
 		     std::size_t numElements = 1);
 
+	void swap(ControlValue &other) noexcept
+	{
+		/* `type_` is a bit field, so `std::swap()` cannot be used. */
+		{
+			auto tmp = type_;
+			type_ = other.type_;
+			other.type_ = tmp;
+		}
+
+		std::swap(isArray_, other.isArray_);
+		std::swap(numElements_, other.numElements_);
+		std::swap(storage_, other.storage_);
+	}
+
+	friend void swap(ControlValue &a, ControlValue &b) noexcept
+	{
+		a.swap(b);
+	}
+
 private:
 	ControlType type_ : 8;
 	bool isArray_;
diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp
index 135e87613..ae54f8c77 100644
--- a/src/libcamera/controls.cpp
+++ b/src/libcamera/controls.cpp
@@ -412,6 +412,21 @@ void ControlValue::reserve(ControlType type, bool isArray, std::size_t numElemen
 		storage_.external = new uint8_t[newSize];
 }
 
+/**
+ * \fn ControlValue::swap(ControlValue &other) noexcept
+ * \brief Swap two control values
+ *
+ * This function swaps the contained value of \a this with that of \a other.
+ */
+
+/**
+ * \fn ControlValue::swap(ControlValue &a, ControlValue &b) noexcept
+ * \brief Swap two control values
+ *
+ * This function swaps the contained value of \a a with that of \a b.
+ * \sa ControlValue::swap()
+ */
+
 /**
  * \class ControlId
  * \brief Control static metadata
