3

In XCode 10.3 I am getting the error message when I try to build -> No template named 'variant' in namespace 'std'

for the lines of code ->

#include <variant>
typedef std::variant<int,double,float,const char*,Mat,Scalar,cv::Point,cv::Size> ocvtypes;

In Build Settings I have tried setting the C++ Language Dialect and C++ Standard Library to different values including C++ 17 but to no avail. This worked before in an earlier version of XCode and the code and project have not changed so I am not sure why this is not working? Also it is finding the variant header file okay.

Adam Freeman
  • 1,271
  • 12
  • 20
  • Which version of clang are you using? There is a chance an old version is used where `` hasn't been implemented yet. [here](https://libcxx.llvm.org/cxx1z_status.html) the clang implementation status for c++17 is listed, with `variant` listed as available from clang 4.0 onwards. – Romeo Valentin Aug 29 '19 at 11:08
  • And of course `` will only be available if at least `std=c++17` is used. – Romeo Valentin Aug 29 '19 at 11:08
  • @RomeoValentin This worked before with a previous version of xcode maybe 10.2 I do not remember what version it was so something changed from the previous version to 10.3 I guess. "Also it is finding the variant header file okay." So the header file is found okay but std::variant is breaking the build. I should add this is for a react native library and I got it working in a standalone app but it is breaking in the react native test app build. – Adam Freeman Aug 29 '19 at 20:26
  • 1
    Did you ever crack this? I'm facing the same on linux using gnu libraries and clang 9.0.0-2 – ericP Mar 17 '20 at 09:19
  • I never cracked this I wound up just not using std::variant. – Adam Freeman Mar 19 '20 at 02:12

0 Answers0