Skip to content

Carry rvalue references through the nbx helper#113

Merged
roystgnr merged 3 commits intolibMesh:masterfrom
lindsayad:carry-rvalue-references-through
Mar 17, 2023
Merged

Carry rvalue references through the nbx helper#113
roystgnr merged 3 commits intolibMesh:masterfrom
lindsayad:carry-rvalue-references-through

Conversation

@lindsayad
Copy link
Copy Markdown
Member

We do so with the public APIs so let's do it with the helper too

We do so with the public APIs so let's do it with the helper too
@lindsayad lindsayad self-assigned this Mar 8, 2023
lindsayad added a commit to lindsayad/moose that referenced this pull request Mar 8, 2023
This makes the `std::moves` being performed in those functors look
a lot less dangerous
@moosebuild
Copy link
Copy Markdown

moosebuild commented Mar 8, 2023

Job Coverage on 1197509 wanted to post the following:

Coverage

Coverage did not change

Full coverage report

This comment will be updated on new commits.

Copy link
Copy Markdown
Member

@loganharbour loganharbour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼 looks good to me

not sure why we didn't do this previously...

Copy link
Copy Markdown
Member

@loganharbour loganharbour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we still test the reference case? I suspect folks have implemented the lambda as non auto and don't pass in an rvalue ref

@lindsayad
Copy link
Copy Markdown
Member Author

if the action functor takes the data as an lvalue reference then with the change here, their code fails to compile, hence why I had to change the unit tests here. But if their action functor takes the data as a const lvalue reference then their code will still work. In MOOSE when compiling the contact module, there was only one action functor I had to change, and it was in the framework LowerDBlocksFromSidesetGenerator

Copy link
Copy Markdown
Member

@loganharbour loganharbour left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should update the doxygen to reflect this; I was just working with @grmnptr and he was confused because the documentation explicitly says you get a const ref to the received containers. Not very intuitive when you're trying to use move semantics

@roystgnr
Copy link
Copy Markdown
Member

But if their action functor takes the data as a const lvalue reference then their code will still work.

And it looks we have TIMPI-internal test coverage on that still? If so then I'm happy here; I never intended an action functor to be able to take a non-const lvalue reference, only a const one.

@lindsayad
Copy link
Copy Markdown
Member Author

Yes, that's right, we still have examples in the TIMPI test suite of action functors taking const lvalue references

@lindsayad
Copy link
Copy Markdown
Member Author

@roystgnr I'm going to wait until you approve before merging

Copy link
Copy Markdown
Member

@roystgnr roystgnr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always hate having to change a test case or user code, but we really did never intend to support non-const lvalue references there.

@roystgnr roystgnr merged commit b62bac5 into libMesh:master Mar 17, 2023
@lindsayad lindsayad deleted the carry-rvalue-references-through branch March 18, 2023 00:15
roystgnr added a commit to roystgnr/moose that referenced this pull request Mar 23, 2023
The TIMPI docs always said we require action functors to take *const*
lvalue references, but we seem to have never actually enforced that
until we added the rvalue reference support.

Refs libMesh/TIMPI#113 , where Alex
describes making this change but I guess didn't actually push this
change?

This fixes libMesh/libmesh#3500 for me, and
it'll be needed for the next libMesh submodule update too.

Refs #000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants