Skip to content

Instantly share code, notes, and snippets.

@gabrielschulhof
Created December 29, 2018 01:53
Show Gist options
  • Save gabrielschulhof/b3a76e1b3c444a517161a2e6b2aedfbd to your computer and use it in GitHub Desktop.
Save gabrielschulhof/b3a76e1b3c444a517161a2e6b2aedfbd to your computer and use it in GitHub Desktop.
#include <stdio.h>
class Signature;
class FunctionTemplate;
template <class V8Type>
class Local {
public:
// Local(const char* x, Local<FunctionTemplate> y):
// val_(nullptr), realval_(x, y) {}
// Local(int x, Local<Signature> y):
// val_(nullptr), realval_(x, y) {}
Local(): val_(nullptr) {}
~Local() {
delete val_;
}
private:
friend class Signature;
friend class FunctionTemplate;
explicit inline Local(V8Type* that) : val_(that) {}
V8Type* val_;
// V8Type realval_;
};
class Signature {
public:
inline Signature() {}
inline Signature(const char* x, Local<FunctionTemplate> tpl) {}
static inline Local<Signature> New(const char* x,
Local<FunctionTemplate> y = Local<FunctionTemplate>()) {
// return Local<Signature>(x, y);
return Local<Signature>(new Signature(x, y));
}
};
class FunctionTemplate {
public:
inline FunctionTemplate() {}
inline FunctionTemplate(int x, Local<Signature> y) {}
static inline Local<FunctionTemplate> New(int x,
Local<Signature> y = Local<Signature>()) {
// return Local<FunctionTemplate>(x, y);
return Local<FunctionTemplate>(new FunctionTemplate(x, y));
}
};
int main() {
auto a = FunctionTemplate::New(5);
auto b = Signature::New("abc");
return 0;
}
// tmp.cc: In instantiation of 'class Local<FunctionTemplate>':
// tmp.cc:9:51: required from here
// tmp.cc:22:10: error: 'Local<V8Type>::realval_' has incomplete type
// V8Type realval_;
// ^~~~~~~~
// tmp.cc:4:7: note: forward declaration of 'class FunctionTemplate'
// class FunctionTemplate;
// ^~~~~~~~~~~~~~~~
// tmp.cc: In instantiation of 'class Local<Signature>':
// tmp.cc:11:36: required from here
// tmp.cc:22:10: error: 'Local<V8Type>::realval_' has incomplete type
// V8Type realval_;
// ^~~~~~~~
// tmp.cc:3:7: note: forward declaration of 'class Signature'
// class Signature;
// ^~~~~~~~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment