TartanLlama / optional

C++11/14/17 std::optional with functional-style extensions and reference support
https://tl.tartanllama.xyz
Creative Commons Zero v1.0 Universal
859 stars 67 forks source link

Compile error with Clang 3.4 #11

Closed ubruhin closed 6 years ago

ubruhin commented 6 years ago

Hi, thanks for this nice library!

Unfortunately it doesn't compile with Clang 3.4 (which is shipped with Ubuntu Trusty, and thus also installed on Travis-CI). I see in your readme that you tested with Clang >= 3.5. Would it be hard to add support for Clang 3.4?

Following compile errors occur:

$ clang++ -std=c++11 optional.hpp

../libs/optional/tl/optional.hpp:388:27: error: no member named 'is_trivially_copy_constructible' in namespace 'std'
template <class T, bool = TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T)>
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../libs/optional/tl/optional.hpp:60:8: note: expanded from macro 'TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE'
  std::is_trivially_copy_constructible<T>::value
  ~~~~~^
../libs/optional/tl/optional.hpp:388:71: error: 'T' does not refer to a value
template <class T, bool = TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T)>
                                                                      ^
../libs/optional/tl/optional.hpp:60:40: note: expanded from macro 'TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE'
  std::is_trivially_copy_constructible<T>::value
                                       ^
../libs/optional/tl/optional.hpp:388:17: note: declared here
template <class T, bool = TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T)>
                ^
../libs/optional/tl/optional.hpp:388:27: error: no type named 'value' in the global namespace
template <class T, bool = TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T)>
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../libs/optional/tl/optional.hpp:60:44: note: expanded from macro 'TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE'
  std::is_trivially_copy_constructible<T>::value
                                         ~~^
../libs/optional/tl/optional.hpp:388:73: error: expected unqualified-id
template <class T, bool = TL_OPTIONAL_IS_TRIVIALLY_COPY_CONSTRUCTIBLE(T)>
                                                                        ^
../libs/optional/tl/optional.hpp:395:8: error: no template named 'optional_copy_base'; did you mean 'optional_storage_base'?
struct optional_copy_base<T, false> : optional_operations_base<T> {
       ^~~~~~~~~~~~~~~~~~
       optional_storage_base
../libs/optional/tl/optional.hpp:302:8: note: 'optional_storage_base' declared here
struct optional_storage_base {
       ^
../libs/optional/tl/optional.hpp:398:3: error: C++ requires a type specifier for all declarations
  optional_copy_base() = default;
  ^~~~~~~~~~~~~~~~~~
../libs/optional/tl/optional.hpp:399:28: error: unknown type name 'optional_copy_base'; did you mean 'optional_storage_base'?
  optional_copy_base(const optional_copy_base &rhs) {
                           ^~~~~~~~~~~~~~~~~~
                           optional_storage_base
../libs/optional/tl/optional.hpp:395:8: note: 'optional_storage_base' declared here
struct optional_copy_base<T, false> : optional_operations_base<T> {
       ^
../libs/optional/tl/optional.hpp:399:3: error: C++ requires a type specifier for all declarations
  optional_copy_base(const optional_copy_base &rhs) {
  ^~~~~~~~~~~~~~~~~~
../libs/optional/tl/optional.hpp:407:22: error: unknown type name 'optional_copy_base'; did you mean 'optional_storage_base'?
  optional_copy_base(optional_copy_base &&rhs) = default;
                     ^~~~~~~~~~~~~~~~~~
                     optional_storage_base
../libs/optional/tl/optional.hpp:395:8: note: 'optional_storage_base' declared here
struct optional_copy_base<T, false> : optional_operations_base<T> {
       ^
../libs/optional/tl/optional.hpp:407:3: error: C++ requires a type specifier for all declarations
  optional_copy_base(optional_copy_base &&rhs) = default;
  ^~~~~~~~~~~~~~~~~~
../libs/optional/tl/optional.hpp:408:3: error: unknown type name 'optional_copy_base'; did you mean 'optional_storage_base'?
  optional_copy_base &operator=(const optional_copy_base &rhs) = default;
  ^~~~~~~~~~~~~~~~~~
  optional_storage_base
../libs/optional/tl/optional.hpp:395:8: note: 'optional_storage_base' declared here
struct optional_copy_base<T, false> : optional_operations_base<T> {
       ^
../libs/optional/tl/optional.hpp:408:39: error: unknown type name 'optional_copy_base'; did you mean 'optional_storage_base'?
  optional_copy_base &operator=(const optional_copy_base &rhs) = default;
                                      ^~~~~~~~~~~~~~~~~~
                                      optional_storage_base
../libs/optional/tl/optional.hpp:395:8: note: 'optional_storage_base' declared here
struct optional_copy_base<T, false> : optional_operations_base<T> {
       ^
../libs/optional/tl/optional.hpp:409:3: error: unknown type name 'optional_copy_base'; did you mean 'optional_storage_base'?
  optional_copy_base &operator=(optional_copy_base &&rhs) = default;
  ^~~~~~~~~~~~~~~~~~
  optional_storage_base
../libs/optional/tl/optional.hpp:395:8: note: 'optional_storage_base' declared here
struct optional_copy_base<T, false> : optional_operations_base<T> {
       ^
../libs/optional/tl/optional.hpp:409:33: error: unknown type name 'optional_copy_base'; did you mean 'optional_storage_base'?
  optional_copy_base &operator=(optional_copy_base &&rhs) = default;
                                ^~~~~~~~~~~~~~~~~~
                                optional_storage_base
../libs/optional/tl/optional.hpp:395:8: note: 'optional_storage_base' declared here
struct optional_copy_base<T, false> : optional_operations_base<T> {
       ^
../libs/optional/tl/optional.hpp:418:32: error: no template named 'is_trivially_move_constructible' in namespace 'std'; did you mean 'is_trivially_destructible'?
template <class T, bool = std::is_trivially_move_constructible<T>::value>
                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                               is_trivially_destructible
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/type_traits:1204:12: note: 'is_trivially_destructible' declared here
    struct is_trivially_destructible
           ^
../libs/optional/tl/optional.hpp:419:29: error: no template named 'optional_copy_base'; did you mean 'optional_move_base'?
struct optional_move_base : optional_copy_base<T> {
                            ^~~~~~~~~~~~~~~~~~
                            optional_move_base
../libs/optional/tl/optional.hpp:419:8: note: 'optional_move_base' declared here
struct optional_move_base : optional_copy_base<T> {
       ^
../libs/optional/tl/optional.hpp:420:9: error: no template named 'optional_copy_base'; did you mean 'optional_move_base'?
  using optional_copy_base<T>::optional_copy_base;
        ^~~~~~~~~~~~~~~~~~
        optional_move_base
../libs/optional/tl/optional.hpp:419:8: note: 'optional_move_base' declared here
struct optional_move_base : optional_copy_base<T> {
       ^
../libs/optional/tl/optional.hpp:425:58: error: no template named 'optional_copy_base'; did you mean 'optional_move_base'?
template <class T> struct optional_move_base<T, false> : optional_copy_base<T> {
                                                         ^~~~~~~~~~~~~~~~~~
                                                         optional_move_base
../libs/optional/tl/optional.hpp:419:8: note: 'optional_move_base' declared here
struct optional_move_base : optional_copy_base<T> {
       ^
../libs/optional/tl/optional.hpp:426:9: error: no template named 'optional_copy_base'; did you mean 'optional_move_base'?
  using optional_copy_base<T>::optional_copy_base;
        ^~~~~~~~~~~~~~~~~~
        optional_move_base
../libs/optional/tl/optional.hpp:419:8: note: 'optional_move_base' declared here
struct optional_move_base : optional_copy_base<T> {
       ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
ubruhin commented 6 years ago

Ah, with -stdlib=libc++ (after sudo apt-get install libc++-dev) it works properly.

Sorry, my bad ;)