Issues with 4.22 C++17 Support

I’m currently experimenting with the advertised support for C++17 in 4.22 but running into a number of issues getting a build together.

I’m building from the “release” branch of the github version in VS2017. My current test is rather simple, as follows:

  1. Download and build the release editor branch following the given instructions in VS2017.

  2. Create a new blank C++ project.

  3. Add the following lines to the constructors in both Target.cs files:

BuildEnvironment = TargetBuildEnvironment.Unique;

CppStandard = CppStandardVersion.Cpp17;

  1. Put in some C++17-only features as dummy code, like creating an std::variant or using an if constexpr.

What I’m noticing is that the entire engine is being rebuilt against the C++17 standard, which seems to break a number of the engine libraries. Some are just warnings, like OpenExr using the since-removed “register” keyword, or multiple libraries using conditional noexcepts (which were also removed in C++17). Some are breaking changes, however. ArraySampleKey.h uses the since-removed std::binary_function and std::unary_function structs, which will no longer compile under C++17.

The 4.22 announcement is pretty light on details on how to use C++17 beyond adding the CppStandard line I included above to your project. Is there more to it that I’m missing? Has someone out there successfully gotten a full source build running on a project that uses C++17 code and features?

Any help would be appreciated. Thanks!

I’ve enabled the C++17 mode for everything (by changing the default of CppStandard in TargetRules.cs) and it does not seem to cause any problems outside of some special plugins like alembic, which we don’t use anyway so it’s no problem.

Someone made a pull request to fix the issues you mentioned.

I currently having issues with CppStandardVersion.Cpp17. I have set BuildEnvironement to Unique and CppStandard to Cpp17. Others in other forums have said to set PCHUsage = PCHUsageMode.NoSharedPCHs; However, when I try to #include and then the line std::variant TestVariant; I get a compile error saying that there is no member named ‘variant’ in namespace ‘std’. How would I use c++17 types in UE 4.22? I am stuck.

Not just in Unreal, but across pretty much all software development that I’ve been involved with, people avoid std like the plague.

Unreal’s ones are based on std libraries, so they are not so bad… also I’ve worked for some AAA companies with in-house engines that uses std as containers (even RTTI which well controlled could be also good)

Sure, that’s not to say that it’s not used anywhere (otherwise, why would they keep adding to it…)… though having been a developer for a lot longer than most people :smiley: i have never actually used std, because it’s never been used in anything that i’ve had to work on, and it just barely existed when I learned to program. :smiley: That doesn’t help pottengermd, though, unfortunately. I was trying to point out that perhaps using std isn’t the best of ideas, although i don’t know what the alternative would be, since i don’t know std.