Skip to content

Re-work OrtApi struct to satisfy C++20 compilers#15183

Merged
yuslepukhin merged 3 commits intomainfrom
yuslepukhin/ortapi_noncopyable
Mar 24, 2023
Merged

Re-work OrtApi struct to satisfy C++20 compilers#15183
yuslepukhin merged 3 commits intomainfrom
yuslepukhin/ortapi_noncopyable

Conversation

@yuslepukhin
Copy link
Copy Markdown
Member

Description

Remove deletion of copy functions from OrtApi as its initialization no longer compiles in C++20.
Introduce a non-copyable member to implicitly delete copy ctor.

Motivation and Context

Inspired by #14901

Solution credits: @RyanUnderhill

Cc: @georgthegreat

@RyanUnderhill
Copy link
Copy Markdown
Contributor

Talked to Dmitri about it and based on the hassle this is causing between the different compilers and different C++ versions, I said I'm fine just deleting the no copy preventer.

Not worth the hassle just to prevent an accidental super minor perf issue if someone does copy this structure.

NoCopy(const NoCopy&) = delete;
NoCopy& operator=(const NoCopy&) = delete;
};
NoCopy m_no_copy;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

naming suggestion: NonCopyable non_copyable_;

@yuslepukhin yuslepukhin marked this pull request as ready for review March 24, 2023 11:47
@yuslepukhin yuslepukhin reopened this Mar 24, 2023
@yuslepukhin yuslepukhin merged commit 2de15c5 into main Mar 24, 2023
@yuslepukhin yuslepukhin deleted the yuslepukhin/ortapi_noncopyable branch March 24, 2023 20:52
@georgthegreat
Copy link
Copy Markdown
Contributor

Thanks @yuslepukhin!

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