1 Reply
      Latest reply on Feb 26, 2020 3:12 AM by ceztko
      JetForMe Level 1 Level 1 (0 points)

        std::optional is more-or-less avialable in Xcode 10.3, with the language dialect set to C++17, but not if the deployment target is less than iOS 12. std::optional is availble, but not value() methods of the class.

         

        I don't understand why a particular iOS runtime is needed to support something in the C++ standard (template) library.

         

        We can't give up support for iOS 11 until well after iOS 13 is out.

         

        I've seen some stuff around setting

         

        _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS

         

        This seems to be defined by Xcode as

         

        __attribute__((availability(ios,strict,introduced=12.0)))

         

        Is there really no way to get full optional support AND target iOS 11.x?

        • Re: Xcode 10.3 and std::optional, requires iOS 12?
          ceztko Level 1 Level 1 (0 points)

          I experienced the same. The check in this case is too strict since optional is an header only library so it should be available indenpendently of the avaiable runtime, and compilation would fail anyway. Just looking at where the macro is defined[1] I discovered you can just define:

           

          _LIBCPP_DISABLE_AVAILABILITY

           

          to disable the availability mechanism as a whole, effectively working around the problem.

           

          By the way, I recommend you to post your development questions also to StackOverflow to have more chances to find answers quickly. It's so unconfortable to find posts on forum with exactly the same problem and zero answers.

           

          [1] https://github.com/llvm-mirror/libcxx/blob/master/include/__config