Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug deduced type? #36

Open
ehuhtala opened this issue Oct 9, 2017 · 4 comments
Open

debug deduced type? #36

ehuhtala opened this issue Oct 9, 2017 · 4 comments

Comments

@ehuhtala
Copy link

ehuhtala commented Oct 9, 2017

Would it be possible to output what a deduced type looks like?

E.g. for lambda, I'm thinking something like:

auto f = f=4{};
using f_type = std::decay<decltype(f)>::type;

constexpr {
compiler.debug($f_type);
}

Or for templates:

template
void func() {
constexpr {
compiler.debug($T);
}
}

@asutton
Copy link
Owner

asutton commented Oct 17, 2017

Fixed in the injection-2 branch.

@ehuhtala
Copy link
Author

Works very well for the first case, thanks :)

Can the constexpr {} block be inside class/function scopes? or just global scope? e.g. the template example still doesn't work due to:

blah.cpp:102:5: error: expression is not an integral constant expression
constexpr {
^
blah.cpp:102:5: note: non-literal type '(lambda at blah.cpp:102:5)' cannot be used in a constant expression

@ehuhtala
Copy link
Author

Looks like the error is specific to templated functions/classes. If they are non-templated, the constexpr{} block works as I'm expecting.

@ehuhtala
Copy link
Author

in template classes, the error looks like:
blah.cpp:15:5: error: expression is not an integral constant expression constexpr { ^ blah.cpp:16:9: note: non-literal type '<dependent type>' cannot be used in a constant expression compiler.debug($T); ^ note: in call to '__constexpr_decl()'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants