Skip to content

Commit

Permalink
Add internal port/cpl_std_ext.h to emulate C++20 features
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Mar 12, 2024
1 parent c24b95c commit 457ba22
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions port/cpl_std_ext.h
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

0 comments on commit 457ba22

Please sign in to comment.