Menu

#2 References to tr1 don't work with C++11

2.1.6
closed
None
2014-11-03
2014-04-25
No

There are references to various names in the std::tr1 namespace; these do not work with C++11. Identified using: Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)

Simply replacing all instances of std::tr1:: to std:: makes everything work. Thus,

#if __cplusplus <= 201103L

should make it possible to use C++11 as well as TR1 compilers.

Discussion

  • Sylvain Bougerel

    Hi Ed,

    I will look into fixing this issue into the next release. I've been dragging my feet about it, because I though I could make the switch to C++11 quite soon, but it's going to need a bit more work from me.

    Anyway, it should be fix in the next few days.

    Thanks for reporting this issue in any case.

    Regards,
    Sylvain

     
  • Sylvain Bougerel

    • status: open --> accepted
     
  • Sylvain Bougerel

    • Milestone: 2.1.4 --> 2.1.6
     
  • Sylvain Bougerel

    (edited: markdown got me...)

    After my own testing it seems that neither GCC(4.9.1), Clang(3.5) nor Windows MSVC++(2012) actually declare that they are __cplusplus >= 201103L when compiling with C++11 switches.

    But I think I originally misunderstood where your issue comes from. It not a C++11 issue, it's a libc++ vs. other libraries issue. Since you are on Apple, probably, you are using Xcode, which comes with libc++; not glibc++. Its probably what you were trying to explain but I focused on C++11 instead.

    Long story short... My fix will look like that, and I believe that should solve your problem:

    #ifdef __LIBCPP_VERSION
    #  include <type_traits>
    namespace spatial
    {
      using std::is_arithmetic;
    }
    #else
    #  ifdef __GLIBCXX__
    #    include <tr1/type_traits>
    #  else
    #    ifdef __IBMCPP__
    #      define __IBMCPP_TR1__
    #    endif
    #    include <type_traits>
    #  endif
    namespace spatial
    {
      using std::tr1::is_arithmetic;
      // etc...
    }
    #endif
    

    I have installed libc++ headers and ABI on my machine, and I can confidently reproduce the error you mention, so I'm going to make it a default test from now on... For the benefit of the Apple and libc++ users out there.

    Let me know if you think the solution looks right to you.

     

    Last edit: Sylvain Bougerel 2014-10-23
  • Sylvain Bougerel

    Wrong!

    After my own testing it seems that neither GCC(4.9.1), Clang(3.5) nor Windows MSVC++(2012) actually declare that they are __cplusplus >= 201103L when compiling with C++11 switches.

    My own testing was wrong. They do define it, so I'm not sure what I did wrong when I tested. Anyway. I fixed it to:

    #if defined(__LIBCPP_VERSION) || __cplusplus >= 201103L
    #  include <type_traits>
    #  define SPATIAL_TYPE_TRAITS_NAMESPACE std
    #elif defined(__GLIBCXX__)
    #  include <tr1/type_traits>
    #  define SPATIAL_TYPE_TRAITS_NAMESPACE std::tr1
    #else
    #  ifdef __IBMCPP__
    #    define __IBMCPP_TR1__
    #  endif
    #  include <type_traits>
    #  define SPATIAL_TYPE_TRAITS_NAMESPACE std::tr1
    #endif
    

    Voila.

     
  • Sylvain Bougerel

    The new release 2.1.6 contains the fix to this issue. It introduces support for libc++ and C++11, so it should work for you.

     
  • Sylvain Bougerel

    • status: accepted --> closed
     
  • Ed Baskerville

    Ed Baskerville - 2014-11-03

    Thanks for fully investigating this and fixing it! Much appreciated.

     

Anonymous
Anonymous

Add attachments
Cancel