-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
adds full impl for std allocator conformance #2227
Conversation
Oh actually we don't need this anymore. It's pretty simple to add though so I'll leave it open if you have time to review it @t4c1 |
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
|
||
/** | ||
* Allocates space for `n` items of type `T`. | ||
* | ||
* @param n number of items to allocate space for | ||
* @return pointer to allocated space | ||
*/ | ||
T* allocate(std::size_t n) { | ||
static inline T* allocate(std::size_t n) noexcept { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why noexcept? Allocations can throw!
constexpr arena_allocator() noexcept {}; | ||
|
||
template <class U> | ||
constexpr arena_allocator(const arena_allocator<U>&) noexcept {} | ||
|
||
template <class U> | ||
constexpr arena_allocator<T>& operator=(const arena_allocator<U>&) noexcept { | ||
return *this; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to explicitely define these, as the implementations are the same as defaults.
new (static_cast<void*>(p)) T(val); | ||
} | ||
|
||
static inline void destroy(pointer p) { (static_cast<T*>(p))->~T(); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for cast. p is of type T*. I would prefere if you used T*
/ T&
everywhere instead of typedefs, so such mistakes would not happen.
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
Closing this because idt we need it |
Summary
Adds full conformance for
arena_allocator
. For multi indexing onvar<matrix>
types I needstd::unordered_set
which requires some additional member functions thatstd::vector<>
does not.Tests
Tests we added to make sure std::unordered_set compiles and handles mem correctly.
Side Effects
We should be able to use
arena_allocator<>
with the other allocator aware classes in the standard library.Release notes
Makes
arena_allocator
standard compliantChecklist
Math issue #(issue number)
Copyright holder: Steve Bronder
The copyright holder is typically you or your assignee, such as a university or company. By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses:
- Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)
- Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
the basic tests are passing
./runTests.py test/unit
)make test-headers
)make test-math-dependencies
)make doxygen
)make cpplint
)the code is written in idiomatic C++ and changes are documented in the doxygen
the new changes are tested