[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-dev
Subject:    [cfe-dev] How to test for std::move (intersection of Apple and Clang)
From:       Jeffrey Walton <noloader () gmail ! com>
Date:       2015-07-31 23:12:00
Message-ID: CAH8yC8koP8Vm_cT56T_yX=BK=iMLZYpMtk-+jOQP405fYoeFYA () mail ! gmail ! com
[Download RAW message or body]

I have the following code:

// R-values: MS at VS2010 (16.00); GCC at 4.3; Clang at 2.9; and Intel 11.1.
//   The extra tests on GCC are because Clang and ICC claims to be GCC 4.
#if (_MSC_VER >= 1600)
# define MY_CXX11_RVALUES 1
#elif defined(__clang__)
# if __has_feature(cxx_rvalue_references)
#  define MY_CXX11_RVALUES 1
# endif
#elif (__INTEL_COMPILER >= 1110)
# define MY_CXX11_RVALUES 1
#elif (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
# define MY_CXX11_RVALUES 1
#endif // R-value compilers

Then guard the rvalue gear in the declaration and implementation:

if MY_CXX11_RVALUES
MyClass::MyClass(MyClass&& t)
    : m_alloc(std::move(t.m_alloc)), m_size(t.m_size), m_ptr(std::move(t.m_ptr))
    {
        t.m_alloc = A();
        t.m_alloc = nullptr;
        t.m_size = 0;
    }
}
#endif

Results in:

    ./myclass.h:276:18: error: no member named 'move' in namespace 'std'
                : m_alloc(std::move(t.m_alloc)), m_size(t.m_size), m_ptr...
                          ~~~~~^
    ./myclass.h:276:65: error: no member named 'move' in namespace 'std'
      ...: m_alloc(std::move(t.m_alloc)), m_size(t.m_size),
m_ptr(std::move(t.m_p...

And the compiler:

    $ c++ -v
    Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
    Target: x86_64-apple-darwin12.6.0
    Thread model: posix

What is the proper way to guard to rvalues and std::move when using
Clang on Apple?
_______________________________________________
cfe-dev mailing list
cfe-dev@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic