/*
 * Copyright 2015 Telenav Inc. All rights reserved.
 *
 * Helper functions to simplify writing code that can be compiled in both 
 * C++11 and C++03 modes (with C++ 11 features falling back to C++ 03 when
 * possible)
 */
#ifndef TN_FOUNDATION_CXX11COMPAT_HPP
#define TN_FOUNDATION_CXX11COMPAT_HPP

#include "foundation/private/config.hpp"

namespace tn {

#if TN_CXX11

#  define TN_CONSTEXPR_OR_CONST constexpr
#  define TN_STATIC_CONSTEXPR static constexpr
#  define TN_NOEXCEPT noexcept
#  define TN_NOEXCEPT_OR_NOTHROW noexcept
#  define TN_NOEXCEPT_IF(Predicate) noexcept((Predicate))
#  define TN_NOEXCEPT_EXPR(Expression) noexcept((Expression))
#  define TN_OVERRIDE override
#  define TN_FINAL final

template <typename T> 
void shrink_to_fit(T& v) {
		v.shrink_to_fit();
}

#else /* TN_CXX11 */  

#  define TN_CONSTEXPR_OR_CONST const
#  define TN_STATIC_CONSTEXPR static const
#  define TN_NOEXCEPT 
#  define TN_NOEXCEPT_OR_NOTHROW throw()
#  define TN_NOEXCEPT_IF(Predicate)
#  define TN_NOEXCEPT_EXPR(Expression) false
#  define TN_OVERRIDE
#  define TN_FINAL

template <typename T> 
void shrink_to_fit(T& vec) {
		T(vec).swap(vec);
}

#endif // TN_CXX11


} // namespace tn

#endif /* TN_FOUNDATION_CXX11COMPAT_HPP */
