Skip to content

Commit

Permalink
Prevent MutableVectorData from being used for std::string.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 705972216
  • Loading branch information
TensorFlow Federated Team authored and copybara-github committed Dec 13, 2024
1 parent 8fa237b commit 812d6bd
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,21 @@
#include <cstddef>
#include <memory>
#include <string>
#include <type_traits>
#include <vector>

#include "absl/strings/string_view.h"
#include "tensorflow_federated/cc/core/impl/aggregation/core/tensor_data.h"

namespace tensorflow_federated {
namespace aggregation {

// MutableVectorData implements TensorData by wrapping std::vector and using it
// as a backing storage. MutableVectorData can be mutated using std::vector
// methods.
template <typename T>
// methods. Use MutableStringData instead if the type is std::string.
template <typename T, std::enable_if_t<std::is_arithmetic_v<T> ||
std::is_same_v<T, absl::string_view>,
int> = 0>
class MutableVectorData : public std::vector<T>, public TensorData {
public:
// Derive constructors from the base vector class.
Expand Down

0 comments on commit 812d6bd

Please sign in to comment.