KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
l_cxx11.h
Go to the documentation of this file.
1 /* $Id$ */
2 /* {{{=========================================================================== *
3  |
4  | Copyright (c) 1994-2014 by Kobus Barnard (author)
5  |
6  | Personal and educational use of this code is granted, provided that this
7  | header is kept intact, and that the authorship is not misrepresented, that
8  | its use is acknowledged in publications, and relevant papers are cited.
9  |
10  | For other use contact the author (kobus AT cs DOT arizona DOT edu).
11  |
12  | Please note that the code in this file has not necessarily been adequately
13  | tested. Naturally, there is no guarantee of performance, support, or fitness
14  | for any particular task. Nonetheless, I am interested in hearing about
15  | problems that you encounter.
16  |
17  | Author: Kyle Simek
18  * =========================================================================== }}}*/
19 
20 // vim: tabstop=4 shiftwidth=4 foldmethod=marker
21 
22 #ifndef KJB_L_CPP_L_CXX11_H
23 #define KJB_L_CPP_L_CXX11_H
24 
25 #ifdef KJB_HAVE_CXX11
26 #include <utility>
27 #include <type_traits>
28 namespace kjb { // passthrough
29  template <typename T>
30  inline typename std::remove_reference<T>::type&& move(T&& v)
31  {
32  return std::move(v);
33  }
34 
35 #ifdef KJB_HAVE_CXX14
36  template <typename T>
37  inline constexpr typename std::remove_reference<T>::type&& move(T&& v)
38  {
39  return std::move(v);
40  }
41 #endif /* KJB_HAVE_CXX14 */
42 }
43 
44 #define KJB_STATIC_ASSERT(x,y) static_assert(x,y)
45 
46 #else /* !KJB_HAVE_CXX11 */
47 namespace kjb { // C++11 emulation
48  template <typename T>
49  inline T& move(T& v) { return v; }
50 
51  template <typename T>
52  inline const T& move(const T& v) { return v; }
53 }
54 
55 #define KJB_STATIC_ASSERT(x,y) typedef char __STATIC_ASSERT__[( x )?1:-1]
56 #endif /* KJB_HAVE_CXX11 */
57 
58 #endif /* KJB_L_CPP_L_CXX11_H */
T & move(T &v)
Definition: l_cxx11.h:49
const T & move(const T &v)
Definition: l_cxx11.h:52