6

This is a followup for another question which is already resolved. But then, I receive this error:

error: no template named 'is_same_v' in namespace 'std'; did you mean 'is_same'?
    !std::is_same_v<typename std::iterator_traits<T>::value_type, void>, O
     ~~~~~^~~~~~~~~
          is_same
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/type_traits:831:61: note: 'is_same' declared here
template <class _Tp, class _Up> struct _LIBCPP_TEMPLATE_VIS is_same           : public false_type {};
                                                            ^

Based on previous answer:

... it was added in C++14, as were most of the other type trait *_t versions ... C++17 added *_v versions as inline constexpr variables ...

So, is_same_v is added by C++17. But I already add C++14 and C++17 to QMake by:

CONFIG += c++14
CONFIG += c++17
QMAKE_CXXFLAGS += -std=c++14
QMAKE_CXXFLAGS += -std=c++17

Is it possible that XCode (Clang) lacks some C++17 features? My Xcode version is 9.4.1 and my Clang++ version is:

$ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -v
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Code

There are both C++14 *_t type trait versions and C++17 *_v versions in the code which is from a repository with many contributors:

template<class T, class O = T>
using IteratorOnly = std::enable_if_t<
    !std::is_same_v<typename std::iterator_traits<T>::value_type, void>, O
>;

Observation

When I use CONFIG += c++14 in QMake project file, I receive only this error:

  • enable_if_t is fine and is_same_v is bad

error: no template named 'is_same_v' in namespace 'std'; did you mean 'is_same'?

When I use CONFIG += c++17 in QMake project file, I receive both these error:

  • both enable_if_t and is_same_v are bad

error: no template named 'enable_if_t' in namespace 'std'; did you mean 'enable_if'?

error: no template named 'is_same_v' in namespace 'std'; did you mean 'is_same'?

Why?

Megidd
  • 7,089
  • 6
  • 65
  • 142
  • 8
    C++14 and C++17 flags are mutually exclusive. You only compile with a *single* standard version. Just remove all references to C++14. – StoryTeller - Unslander Monica Oct 09 '20 at 19:47
  • @StoryTeller-UnslanderMonica When I remove all references to C++14, and keep just C++17, I receive unknown `enable_if_t` error! – Megidd Oct 09 '20 at 20:20
  • 1
    Sounds like a bad installation of the standard library/compiler. The `_t` type traits are available in C++14 going forward. Meaning they are available in C++17 too, and so specifying that isn't supposed to make them stop working. – StoryTeller - Unslander Monica Oct 09 '20 at 20:21
  • 1
    I don't think xcode 9 has full c++17 support, is there a reason you're using an old version? – Alan Birtles Oct 09 '20 at 21:11

1 Answers1

0

The tool chain was not capable of C++17. Therefore, eventually, replaced std::is_same_v with std::is_same with this approach ...

Megidd
  • 7,089
  • 6
  • 65
  • 142