|
UE4的90%以上是用C++写的,所以。。。严格的来说没有UE4的C++,基本语法、用法、规范都是C++
需要单独学C++吗?当然,而且是必须,甚至至少需要学到C++11
需要单独学STL吗,没有精通的必要,但事实上如果了解STL的话会有帮助
Unreal不推荐直接使用STL,但并不阻止你使用STL,至于他本身没有用STL的原因
From Tim Sweeny:The Unreal Engine's avoidance of the C++ standard library's containers is primarily historical. C++ was standardized in 1998, the same year we shipped the first Unreal Engine game.
Back then, the standard libraries were controversial, poorly-implemented, and very inconsistent between platforms. They made very aggressive use of new C++ features that hadn't yet been production-proven, and had some significant problems interoperating with C libraries. For example, std::vector wasn't guaranteed to be contiguous, so passing an array to a C library like DirectX could potentially involve creating a temporary copy of it.
The standard containers are very stable now, and I don't think it would be too hard to compatibly evolve UE4 to use them if we chose to, through some #define's and implementations of the existing TArray and TMap operations that could be deprecated over time. ”UE4的C++“和”一般的C++“的不同在于他有一套自己的"STL"。接口和实现上会有些许不同,但是思路上是一致的:- std::vector - TArray
- std::map - TMap
- std::shared_ptr - TSharedPtr
- std::move - MoveTemp
复制代码 等等等等,事实上如果你std::shared_ptr用的很6,你会发现在ue4里面他只是换了个名字叫TSharedPtr。如果你对std::map很熟悉,你会发现TMap虽然并非完全一样,但是并不会影响你迅速理解并使用。
除此之外,因为unreal的垃圾回收和反射(这些都是unreal在引擎里用C++实现的,并不是一种"特殊的C++"),很多类、结构、成员变量的声明前面会需要加上一个前置的宏声明,但是这些跟”先学会C++“没有任何冲突,只是你在用UE4的时候需要额外学习或者了解的一些东西 |
|