diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2022-11-26 01:27:04 +0000 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2022-11-26 01:27:04 +0000 |
commit | 15692f0e89a75131a56732b828ba88a82fa67203 (patch) | |
tree | 4e60b406d78f0b62c7c5e76fd1211c0b5e1f0569 /Examples | |
parent | 2a1711e4364afe0250282e032650e3ac543e73a3 (diff) | |
download | swig-15692f0e89a75131a56732b828ba88a82fa67203.tar.gz |
Add missing testcase cpp11_template_parameters_decltype
Diffstat (limited to 'Examples')
-rw-r--r-- | Examples/test-suite/cpp11_template_parameters_decltype.i | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/Examples/test-suite/cpp11_template_parameters_decltype.i b/Examples/test-suite/cpp11_template_parameters_decltype.i new file mode 100644 index 000000000..ab2c3e4fc --- /dev/null +++ b/Examples/test-suite/cpp11_template_parameters_decltype.i @@ -0,0 +1,51 @@ +%module cpp11_template_parameters_decltype + +%include <std_string.i> +%include <std_vector.i> +%include <std_pair.i> + +#pragma SWIG nowarn=SWIGWARN_CPP11_DECLTYPE + +#if 0 +// to fix (non-template expression equivalent to template expression further down): +%inline %{ +#include <utility> +#include <vector> + void f(bool c = std::is_constructible<std::string, decltype(std::declval<std::vector<std::pair<int, int>>>().begin()->first)>::value) {} +%} +#endif + +%inline %{ +// Github issue #1590 +struct Converter { + std::string to_json() const {} +}; +struct Json { + Json(std::string s) {} + template < class T, class = decltype(&T::to_json) > + Json(const T & t) : Json(t.to_json()) {} + +// Github issue #1589 +// To fix +#if !defined(SWIG) + // Implicit constructor: map-like objects (std::map, std::unordered_map, etc) + template <class M, typename std::enable_if< + std::is_constructible<std::string, decltype(std::declval<M>().begin()->first)>::value, + int>::type = 0> + Json(const M & m) : Json(object(m.begin(), m.end())) {} +#endif +}; +%} + +// %template(Json) Json::Json<Converter>; // not working +%template(Json) Json::Json<Converter, std::string>; // workaround + + +%inline %{ +// Github issue #1589 +template <decltype(true) X = true> +void A() { } +%} + +// %template(A) A<>; // not working +%template(A) A<true>; // workaround |