Fix build when std::string is a lone parameter
The "any tuple-like" thing was nice but it was confusing when passing for example a std::string, which is a typedef to a tuple-like thing. Making a custom ConstructorParameters struct is more clear both to users and to the compiler.
This commit is contained in:
parent
ea19e35f85
commit
72da0b8d87
2 changed files with 8 additions and 6 deletions
|
@ -23,11 +23,12 @@
|
|||
# include "guess_class_name.hpp"
|
||||
#endif
|
||||
#include <utility>
|
||||
#include <tuple>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
|
||||
namespace wren {
|
||||
template <typename... Args> struct ConstructorParameters { };
|
||||
|
||||
namespace detail {
|
||||
template <typename T, typename... Args, int... Indices>
|
||||
inline void construct_single (
|
||||
|
@ -46,13 +47,13 @@ namespace wren {
|
|||
template <typename T, typename... Args>
|
||||
struct ForeignClassHelper;
|
||||
|
||||
template <typename T, template <typename...> class Pack, typename... PackArgs, typename... Args>
|
||||
struct ForeignClassHelper<T, Pack<PackArgs...>, Args...> {
|
||||
template <typename T, typename... PackArgs, typename... Args>
|
||||
struct ForeignClassHelper<T, ConstructorParameters<PackArgs...>, Args...> {
|
||||
static ConstructResult construct (VM& vm, int cardinality, void* memory) {
|
||||
using std::make_integer_sequence;
|
||||
|
||||
//search by number of parameters.
|
||||
//once we find a tuple-like parameter that contains the right
|
||||
//once we find a ConstructorParameters that contains the right
|
||||
//number of types we invoke construct_single() with those types.
|
||||
constexpr int pack_size = static_cast<int>(sizeof...(PackArgs));
|
||||
if (pack_size == cardinality) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue