forked from OSGeo/gdal
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add internal port/cpl_std_ext.h to emulate C++20 features
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#ifndef CPL_STD_EXT_H | ||
#define CPL_STD_EXT_H | ||
|
||
/*! @cond Doxygen_Suppress */ | ||
|
||
#if defined(GDAL_COMPILATION) | ||
|
||
#include <map> | ||
#include <set> | ||
|
||
namespace cpl | ||
{ | ||
#if __cplusplus > 201703L | ||
using std::map; | ||
using std::set; | ||
#else | ||
/** Helper offering C++20-like features for std::map */ | ||
template <typename K, typename V> class map : public std::map<K, V> | ||
{ | ||
public: | ||
inline map() = default; | ||
inline bool contains(const K &key) const | ||
{ | ||
return this->find(key) != this->end(); | ||
} | ||
}; | ||
|
||
/** Helper offering C++20-like features for std::set */ | ||
template <typename K> class set : public std::set<K> | ||
{ | ||
public: | ||
inline set() = default; | ||
inline bool contains(const K &key) const | ||
{ | ||
return this->find(key) != this->end(); | ||
} | ||
}; | ||
#endif | ||
} // namespace cpl | ||
|
||
#endif // GDAL_COMPILATION | ||
|
||
/*! @endcond */ | ||
|
||
#endif // CPL_STD_EXT_H |