Skip to content

Conversation

@bartgol
Copy link
Contributor

@bartgol bartgol commented Oct 31, 2025

Motivation

Sometimes we want to create the object, and defer the initialization until the input view is available, like

ViewBroadcast<to_view_t> bcasted_v;
if (input1d) {
  bcasted_v.setup(input.get<view_1d<T>>(),input.dims());
} else {
  bcasted_v.setup(input.get<view_2d<T>>(),input.dims());
}

with current master, we would have to move the whole code that uses bcasted_v into both the if branches,duplicating everything.

Testing

I modified one bcasted view in the unit tests to be default-constructed, and setup later.

@bartgol bartgol merged commit f158d9d into master Nov 3, 2025
4 checks passed
@bartgol bartgol deleted the bartgol/view-bcast-ctor branch November 3, 2025 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants