Here are the key points:
1: This project uses the open-source repository NanoRT as a raytracer in a project.
2: This project is compiled under Visual Studio 2019 (C++17)
3: This project is compiled with warnings treated as errors (and this cannot be changed). Adding the define to suppress these warnings did not help.
However, it looks like part of this code does not work in C++17, as it uses something that has become deprecated: (line 133 and 134 in the link I provided)
typedef typename std::allocator<T>::pointer pointer;
typedef typename std::allocator<T>::size_type size_type;
I need to figure out how to approach fixing this. The error suggests using std::allocator_traits
but I am really unfamiliar with this use of std::allocator
or allocator_traits
.
Looking at the source, is this a few-line fix, or is this much more complicated than that and would require restructuring large portions of the code?
It looks like pointer
is used as the return for allocate()
and the first argument to deallocate()
, with size_type
being used in the same way.
// Actually do the allocation. Use the stack buffer if nobody has used it yet
// and the size requested fits. Otherwise, fall through to the standard
// allocator.
pointer allocate(size_type n, void *hint = 0) {
if (source_ != NULL && !source_->used_stack_buffer_ &&
n <= stack_capacity) {
source_->used_stack_buffer_ = true;
return source_->stack_buffer();
} else {
return std::allocator<T>::allocate(n, hint);
}
}
// Free: when trying to free the stack buffer, just mark it as free. For
// non-stack-buffer pointers, just fall though to the standard allocator.
void deallocate(pointer p, size_type n) {
if (source_ != NULL && p == source_->stack_buffer())
source_->used_stack_buffer_ = false;
else
std::allocator<T>::deallocate(p, n);
}
typedef typename std::allocator<T>::pointer pointer;
withusing pointer = std::allocator_traits<std::allocator<T>>::pointer;
I get a large number of errors. Some syntax, butallocate()
states "unknown override specifier. Is the
using``` syntax the same astypedef typename
here or does the usage need to change? – Tomtit