Skip to content

Commit

Permalink
Forbid assigning to Buffer(Expr) by introducing an intermediate type. (
Browse files Browse the repository at this point in the history
…#7517)

* Forbid assigning to Buffer(Expr) by introducing an intermediate type.

Fixes #7514

* Simpler solution

* Silence clang-tidy
  • Loading branch information
abadams authored Apr 19, 2023
1 parent 8670a25 commit 294f80c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -575,16 +575,19 @@ class Buffer {
}
// @}

/** Make an Expr that loads from this concrete buffer at a computed coordinate. */
/** Make an Expr that loads from this concrete buffer at a computed
* coordinate. Returned Expr is const so that it's not possible to
* accidentally treat a buffer like a Func and try to assign an Expr to a
* given symbolic coordinate. */
// @{
template<typename... Args>
Expr operator()(const Expr &first, Args... rest) const {
const Expr operator()(const Expr &first, Args... rest) const { // NOLINT
std::vector<Expr> args = {first, rest...};
return (*this)(args);
}

template<typename... Args>
Expr operator()(const std::vector<Expr> &args) const {
const Expr operator()(const std::vector<Expr> &args) const { // NOLINT
return buffer_accessor(Buffer<>(*this), args);
}
// @}
Expand Down

0 comments on commit 294f80c

Please sign in to comment.