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

Default for AtomicPtr? #24613

Closed
njwhite opened this issue Apr 19, 2015 · 2 comments · Fixed by #24834
Closed

Default for AtomicPtr? #24613

njwhite opened this issue Apr 19, 2015 · 2 comments · Fixed by #24834
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@njwhite
Copy link

njwhite commented Apr 19, 2015

Is there any reason why there isn't an ATOMIC_PTR_INIT (cf ATOMIC_BOOL_INIT, ATOMIC_ISIZE_INIT, &c.) struct? I'd like to use AtomicPtrs in statically-initialized variables - and AtomicPtr is the only atomic class that doesn't implement the Default trait. A std::ptr::null_mut() seems to be a sensible initial value.

@sfackler
Copy link
Member

You can't define generic consts so ATOMIC_PTR_INIT can't be expressed. We can add a Default implementation though.

@steveklabnik steveklabnik added A-libs C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Apr 20, 2015
@steveklabnik
Copy link
Member

/cc @aturon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants