77
88#pragma once
99
10+ #if __cplusplus < 201703L
11+ #error "embind requires -std=c++17 or newer"
12+ #endif
13+
1014#include < cassert>
1115#include < cstddef>
1216#include < functional>
1317#include < map>
1418#include < string>
1519#include < type_traits>
1620#include < vector>
17- #if __cplusplus >= 201703L
1821#include < optional>
19- #endif
2022
2123#include < emscripten/em_asm.h>
2224#include < emscripten/val.h>
@@ -1591,7 +1593,7 @@ class class_ {
15911593 // overload.
15921594 typename = typename std::enable_if<
15931595 !std::is_function<FieldType>::value &&
1594- internal ::conjunction<internal::isPolicy<Policies>...>::value>::type>
1596+ std ::conjunction<internal::isPolicy<Policies>...>::value>::type>
15951597 EMSCRIPTEN_ALWAYS_INLINE const class_& property (const char * fieldName, const FieldType ClassType::*field, Policies...) const {
15961598 using namespace internal ;
15971599 using ReturnPolicy = GetReturnValuePolicy<FieldType, Policies...>::tag;
@@ -1619,7 +1621,7 @@ class class_ {
16191621 // overload.
16201622 typename = typename std::enable_if<
16211623 !std::is_function<FieldType>::value &&
1622- internal ::conjunction<internal::isPolicy<Policies>...>::value>::type>
1624+ std ::conjunction<internal::isPolicy<Policies>...>::value>::type>
16231625 EMSCRIPTEN_ALWAYS_INLINE const class_& property (const char * fieldName, FieldType ClassType::*field, Policies...) const {
16241626 using namespace internal ;
16251627 using ReturnPolicy = GetReturnValuePolicy<FieldType, Policies...>::tag;
@@ -1648,7 +1650,7 @@ class class_ {
16481650 // Prevent the template from wrongly matching the getter/setter overload
16491651 // of this function.
16501652 typename = typename std::enable_if<
1651- internal ::conjunction<internal::isPolicy<Policies>...>::value>::type>
1653+ std ::conjunction<internal::isPolicy<Policies>...>::value>::type>
16521654 EMSCRIPTEN_ALWAYS_INLINE const class_& property (const char * fieldName, Getter getter, Policies...) const {
16531655 using namespace internal ;
16541656
@@ -1775,7 +1777,6 @@ class class_ {
17751777 }
17761778};
17771779
1778- #if __cplusplus >= 201703L
17791780template <typename T>
17801781void register_optional () {
17811782 // Optional types are automatically registered for some internal types so
@@ -1790,7 +1791,6 @@ void register_optional() {
17901791 internal::TypeID<std::optional<T>>::get (),
17911792 internal::TypeID<typename std::remove_pointer<T>::type>::get ());
17921793}
1793- #endif
17941794
17951795// //////////////////////////////////////////////////////////////////////////////
17961796// VECTORS
@@ -1800,9 +1800,6 @@ namespace internal {
18001800
18011801template <typename VectorType>
18021802struct VectorAccess {
1803- // This nearly duplicated code is used for generating more specific TypeScript
1804- // types when using more modern C++ versions.
1805- #if __cplusplus >= 201703L
18061803 static std::optional<typename VectorType::value_type> get (
18071804 const VectorType& v,
18081805 unsigned int index
@@ -1813,18 +1810,6 @@ struct VectorAccess {
18131810 return {};
18141811 }
18151812 }
1816- #else
1817- static val get (
1818- const VectorType& v,
1819- unsigned int index
1820- ) {
1821- if (index < v.size ()) {
1822- return val (v[index], allow_raw_pointers ());
1823- } else {
1824- return val::undefined ();
1825- }
1826- }
1827- #endif
18281813
18291814 static bool set (
18301815 VectorType& v,
@@ -1860,9 +1845,7 @@ struct VectorAccess {
18601845template <typename T, class Allocator =std::allocator<T>>
18611846class_<std::vector<T, Allocator>> register_vector (const char * name) {
18621847 typedef std::vector<T, Allocator> VecType;
1863- #if __cplusplus >= 201703L
18641848 register_optional<T>();
1865- #endif
18661849
18671850 return class_<VecType>(name)
18681851 .template constructor <>()
@@ -1882,9 +1865,6 @@ namespace internal {
18821865
18831866template <typename MapType>
18841867struct MapAccess {
1885- // This nearly duplicated code is used for generating more specific TypeScript
1886- // types when using more modern C++ versions.
1887- #if __cplusplus >= 201703L
18881868 static std::optional<typename MapType::mapped_type> get (
18891869 const MapType& m,
18901870 const typename MapType::key_type& k
@@ -1896,19 +1876,6 @@ struct MapAccess {
18961876 return i->second ;
18971877 }
18981878 }
1899- #else
1900- static val get (
1901- const MapType& m,
1902- const typename MapType::key_type& k
1903- ) {
1904- auto i = m.find (k);
1905- if (i == m.end ()) {
1906- return val::undefined ();
1907- } else {
1908- return val (i->second );
1909- }
1910- }
1911- #endif
19121879
19131880 static void set (
19141881 MapType& m,
@@ -1940,9 +1907,7 @@ template<typename K, typename V, class Compare = std::less<K>,
19401907 class Allocator = std::allocator<std::pair<const K, V>>>
19411908class_<std::map<K, V, Compare, Allocator>> register_map (const char * name) {
19421909 typedef std::map<K,V, Compare, Allocator> MapType;
1943- #if __cplusplus >= 201703L
19441910 register_optional<V>();
1945- #endif
19461911
19471912 return class_<MapType>(name)
19481913 .template constructor <>()
@@ -1957,7 +1922,6 @@ class_<std::map<K, V, Compare, Allocator>> register_map(const char* name) {
19571922// std::optional
19581923// //////////////////////////////////////////////////////////////////////////////
19591924
1960- #if __cplusplus >= 201703L
19611925namespace internal {
19621926template <typename T>
19631927struct BindingType <std::optional<T>> {
@@ -1982,7 +1946,6 @@ struct BindingType<std::optional<T>> {
19821946 }
19831947};
19841948} // end namespace internal
1985- #endif
19861949
19871950
19881951// //////////////////////////////////////////////////////////////////////////////
0 commit comments