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

[Question]: Specialized template class parameter issue #91

Open
harsszegi opened this issue Jan 25, 2024 · 0 comments
Open

[Question]: Specialized template class parameter issue #91

harsszegi opened this issue Jan 25, 2024 · 0 comments

Comments

@harsszegi
Copy link

harsszegi commented Jan 25, 2024

Hi,
I have the following class:

#include
#include

template<typename DataType, typename Variant1, typename Variant2, typename Variant3>
class Foo
{
public:
Foo(const std::shared_ptr & foo) : foo_{foo} {}
Foo(const std::variant<Variant1, Variant2, Variant3> & bar) : bar_{bar} {}
private:
std::shared_ptr foo_;
std::variant<Variant1, Variant2, Variant3> bar_;
};

using FooInt = Foo<int, double, char, long>;

Even when I check FooInt's attribute, I fail to see for example shared_ptr's template parameter being "resolved" to DataType, instead I get (I guess the STL default) "_Ty" when I check the constructor arguments.

If I do an -ast-dump with clang-15 for example, I can clearly see though that even the unspecialized template class
definition contains the proper arguments for shared_ptr (I don't even see _Ty there), e.g.:

| | |-CXXConstructorDecl 0x56434eb1f3a8 <line:8:3, col:59> col:3 Foo<DataType, Variant1, Variant2, Variant3> 'void (const std::shared_ptr &)' implicit-inline
| | | |-ParmVarDecl 0x56434eb1f270 <col:7, col:41> col:41 referenced foo 'const std::shared_ptr &'
| | | |-CXXCtorInitializer Field 0x56434eb1fa00 'foo_' 'std::shared_ptr':'shared_ptr'
| | | | -InitListExpr 0x56434eb1fcc8 <col:52, col:56> 'void' | | | | -DeclRefExpr 0x56434eb1fca8 col:53 'const std::shared_ptr':'const shared_ptr' lvalue ParmVar 0x56434eb1f270 'foo' 'const std::shared_ptr &'
| | | `-CompoundStmt 0x56434eb1fd38 <col:58, col:59>

How should I / could I figure out that "_Ty" is actually "DataType" (same goes for std::variant's template parameters).
Thanks,

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

1 participant