Skip to content

Commit

Permalink
cxx17 compatability fixes
Browse files Browse the repository at this point in the history
-fixes to build with c++17

https://en.cppreference.com/w/cpp/feature_test#cpp_lib_source_location

Signed-off-by: Joel Winarske <[email protected]>
  • Loading branch information
jwinarske committed Dec 23, 2024
1 parent b7bf486 commit 0bda794
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
4 changes: 3 additions & 1 deletion include/mbgl/gfx/shader_group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ class ShaderGroup {
using PropertyHashType = std::uint64_t;

std::string getShaderName(const std::string_view& name, const PropertyHashType key) {
return (std::ostringstream() << name << '#' << std::hex << key).str();
std::ostringstream oss;
oss << name << '#' << std::hex << key;
return oss.str();
}

/// Generate a map key for the specified combination of properties
Expand Down
12 changes: 5 additions & 7 deletions src/mbgl/layout/symbol_instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
#include <mbgl/style/layers/symbol_layer_properties.hpp>
#include <mbgl/util/bitmask_operations.hpp>

#ifdef __cpp_lib_source_location
#include <source_location>
#endif

#if !defined(MLN_SYMBOL_GUARDS)
#define MLN_SYMBOL_GUARDS 1
Expand All @@ -20,8 +22,9 @@

// A temporary shim for partial C++20 support
#if MLN_SYMBOL_GUARDS
#if defined(__clang__)
#if __cplusplus <= 201703L || !__has_builtin(__builtin_source_location)
#if __cpp_lib_source_location
#define SYM_GUARD_LOC std::source_location::current()
#else
namespace std {
struct source_location {
const char* fileName_;
Expand All @@ -38,11 +41,6 @@ struct source_location {
std::source_location { \
__FILE__, __FUNCTION__, __LINE__ \
}
#else
#define SYM_GUARD_LOC std::source_location::current()
#endif
#else
#define SYM_GUARD_LOC std::source_location::current()
#endif
#else
#define SYM_GUARD_LOC \
Expand Down
4 changes: 3 additions & 1 deletion src/mbgl/util/string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ std::string toString(uint64_t t) {
}

std::string toString(const std::thread::id& t) {
return ((std::stringstream{}) << t).str();
std::stringstream ss;
ss << t;
return ss.str();
}

std::string toString(double t, bool decimal) {
Expand Down

0 comments on commit 0bda794

Please sign in to comment.