Add configure-time check for std::make_unique

Fixes the build on Clang 6 and closes #4685.
This commit is contained in:
David Adam 2018-01-31 13:43:05 +08:00
parent 54cefeb5b1
commit fb53a96a1c
3 changed files with 20 additions and 1 deletions

View file

@ -113,4 +113,14 @@ IF(NOT TPARM_TAKES_VARARGS)
SET(TPARM_SOLARIS_KLUDGE 1)
ENDIF()
CHECK_CXX_SOURCE_COMPILES("
#include <memory>
int main () {
std::unique_ptr<int> foo = std::make_unique<int>();
}
"
HAVE_STD__MAKE_UNIQUE
)
FIND_PROGRAM(SED sed)

View file

@ -400,6 +400,15 @@ AC_TRY_LINK( [ #include <wchar.h> ],
[AC_MSG_RESULT(no)],
)
AC_MSG_CHECKING([for std::make_unique])
AC_TRY_LINK( [ #include <memory> ],
[ std::unique_ptr<int> foo = std::make_unique<int>(); ],
[ AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_STD__MAKE_UNIQUE, 1, Define to 1 if you have the `std::make_unique' function.)
],
[AC_MSG_RESULT(no)],
)
if test x$local_gettext != xno; then
AC_CHECK_FUNCS( gettext )

View file

@ -606,7 +606,7 @@ wcstring vformat_string(const wchar_t *format, va_list va_orig);
void append_format(wcstring &str, const wchar_t *format, ...);
void append_formatv(wcstring &str, const wchar_t *format, va_list ap);
#ifdef __cpp_lib_make_unique
#ifdef HAVE_STD__MAKE_UNIQUE
using std::make_unique;
#else
/// make_unique implementation