From d241703dd2d65f991d1d5c14a25bbdb0d29f4ac4 Mon Sep 17 00:00:00 2001 From: jrkoonce <30676875+jrkoonce@users.noreply.github.com> Date: Tue, 3 Sep 2019 09:48:30 -0500 Subject: [PATCH] Made C++14 optional, default off. --- tiny_gltf.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tiny_gltf.h b/tiny_gltf.h index 9e3c9f8..20fca6e 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -56,6 +56,10 @@ #include #include +#ifndef TINYGLTF_USE_CPP14 +#include +#endif + #ifdef __ANDROID__ #ifdef TINYGLTF_ANDROID_LOAD_FROM_ASSETS #include @@ -4938,7 +4942,13 @@ bool TinyGLTF::LoadFromString(Model *model, std::string *err, std::string *warn, } } +#ifdef TINYGLTF_USE_CPP14 auto ForEachInArray = [](const json& v, const char* member, const auto& cb)->bool +#else + //The std::function<> implementation can be less efficient because it will allocate heap when the size of + //the captured lambda is above 16 bytes with clang and gcc, but it does not require C++14. + auto ForEachInArray = [](const json& v, const char* member, const std::function& cb)->bool +#endif { json_const_iterator it; if (FindMember(v, member, it) && IsArray(GetValue(it))) {