Skip to content

Commit

Permalink
Check if "std::move" is available.
Browse files Browse the repository at this point in the history
  • Loading branch information
fancycode committed Jul 22, 2015
1 parent 35a5de5 commit 5d725da
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
16 changes: 16 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,22 @@ if eval "test x$need_strict_ansi = xyes"; then
fi
AC_MSG_RESULT([$need_strict_ansi])

# Check if "std::move" is available
AC_MSG_CHECKING([for std::move])
AC_LANG_PUSH(C++)
AC_TRY_COMPILE([
#include <utility>
],[
class A {};
A* a = new A();
A* b = std::move(a);
],[has_std_move=yes],[has_std_move=no]);
AC_LANG_POP(C++)
if eval "test x$has_std_move = xno"; then
AC_DEFINE(NEED_STD_MOVE_FALLBACK,1,[Define to 1 if a fallback for "std::move" is required.])
fi
AC_MSG_RESULT([$has_std_move])

# --- machine dependent optimizations ---

#AX_EXT
Expand Down
17 changes: 17 additions & 0 deletions libde265/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#ifndef DE265_UTIL_H
#define DE265_UTIL_H

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#ifndef _MSC_VER
#include <inttypes.h>
#endif
Expand Down Expand Up @@ -70,6 +74,19 @@
namespace std { using namespace std::tr1; }
#endif

#ifdef NEED_STD_MOVE_FALLBACK
// Provide fallback variant of "std::move" for older compilers with
// incomplete/broken C++11 support.
namespace std {

template<typename _Tp>
inline typename std::remove_reference<_Tp>::type&& move(_Tp&& __t) {
return static_cast<typename std::remove_reference<_Tp>::type&&>(__t);
}

} // namespace std
#endif

#if __GNUC__ && GCC_VERSION < 40600
// nullptr was introduced in gcc 4.6, a simple alias should be fine for our use case
#define nullptr NULL
Expand Down

0 comments on commit 5d725da

Please sign in to comment.