13
0

Fix MacOS 10.11 (clang-8.0.0) builds

gcc, and recent clang-10 can construct new objects
using references as arguments.

However clang-8 (and MSVC?) do not:
   "error: no matching function for call to 'operator new'"

The compiler apparently does not expand the template
  class A  <-> `A*`  vs. `A const&`
for different cases.
This commit is contained in:
Robin Gareus 2020-03-09 18:03:13 +01:00
parent 70e2ddbc1b
commit 379115a20e
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -128,17 +128,19 @@ public:
new (p) U ();
}
#if __cplusplus > 201103L || defined __clang__
template <class U, class A>
void construct (U* const p, A& a)
void construct (U* const p, A* const a)
{
new (p) U (a);
}
template <class U, class A, class B>
void construct (U* const p, A& a, B& b)
#else
template <class U, class A>
void construct (U* const p, A const& a)
{
new (p) U (a, b);
new (p) U (a);
}
#endif
private:
StackAllocator& operator= (const StackAllocator&);