Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::is_pod is deprecated in C++20 #1913

Closed
Predelnik opened this issue Jan 23, 2020 · 6 comments · Fixed by #2033
Closed

std::is_pod is deprecated in C++20 #1913

Predelnik opened this issue Jan 23, 2020 · 6 comments · Fixed by #2033
Assignees
Labels
kind: bug release item: 🔨 further change solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Milestone

Comments

@Predelnik
Copy link

Newest msvc preview version already implements warning for this case. While it's not urgent in any way, it might be nice to replace it with either std::is_standard_layout or std::is_trivial to avoid warnings during compilation with newer standard support.

Here you can find more details on its deprecation:
https://stackoverflow.com/questions/48225673/why-is-stdis-pod-deprecated-in-c20

@nlohmann
Copy link
Owner

Thanks for reporting. std::is_pod is used here:

template < typename C = CharType,
           enable_if_t < std::is_signed<C>::value and std::is_unsigned<char>::value > * = nullptr >
static CharType to_char_type(std::uint8_t x) noexcept
{
    static_assert(sizeof(std::uint8_t) == sizeof(CharType), "size of CharType must be equal to std::uint8_t");
    static_assert(std::is_pod<CharType>::value, "CharType must be POD");
    CharType result;
    std::memcpy(&result, &x, sizeof(x));
    return result;
}

I think replacing this with std::is_standard_layout is suitable here, right?

@nlohmann nlohmann added the state: help needed the issue needs help to proceed label Jan 25, 2020
@Predelnik
Copy link
Author

To be able to do memcpy the requirement is std::is_trivially_copyable (stackoverflow link)

std::is_trivial also adds trivial default constructor requirement which might be useful here.

Standard layout however adds a lot of constraints I guess for most of them it's a bit strange to be unsatisfied in hypothetical CharType but I think since operations done are technically correct the rest can be blamed on user for passing something so unorthodox.

My conclusion is that std::is_trivial should be used. But I'm not an expert so it might be nice if someone would confirm my guess.

@nlohmann
Copy link
Owner

I created a branch for this: https://github.com/nlohmann/json/tree/feature/issue1913

@stale
Copy link

stale bot commented Mar 17, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Mar 17, 2020
@dota17
Copy link
Contributor

dota17 commented Mar 17, 2020

@Stale This issue should be pinned.

@nlohmann, hello.
Is there any new progress? It seems that this issue will be closed by bad bot.

@stale stale bot removed the state: stale the issue has not been updated in a while and will be closed automatically soon unless it is updated label Mar 17, 2020
@nlohmann
Copy link
Owner

I have a branch for this an will finish this after my vacation.

@nlohmann nlohmann added solution: proposed fix a fix for the issue has been proposed and waits for confirmation and removed state: help needed the issue needs help to proceed labels Apr 11, 2020
@nlohmann nlohmann self-assigned this Apr 13, 2020
@nlohmann nlohmann added this to the Release 3.7.4 milestone Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug release item: 🔨 further change solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants