Way to deduce if type is from a templated classWhat are POD types in C++?What's the canonical way to check for type in Python?Use 'class' or 'typename' for template parameters?How to determine a Python variable's type?Why can templates only be implemented in the header file?Where and why do I have to put the “template” and “typename” keywords?Why is the C++ STL is so heavily based on templates? (and not on *interfaces*)What are the differences between type() and isinstance()?Explanation of <script type = “text/template”> … </script>Easiest way to convert int to string in C++
Understanding data transmission rates over copper wire
Which is the correct version of Mussorgsky's Pictures at an Exhibition?
Sandwich Sudoku: First 12 digits of pi
How do I keep my animals from eating my people food?
How were US credit cards verified in-store in the 1980's?
Why do presidential pardons exist in a country having a clear separation of powers?
Get contents before a colon
I was given someone else's visa, stamped in my passport
Can I lend a small amount of my own money to a bank at the federal funds rate?
Strange behavior of std::initializer_list of std::strings
Is the word 'mistake' a concrete or abstract noun?
IList<T> implementation
Ask one verbal question to figure out who is blind and who is mute among three persons
What's the origin of the concept of alternate dimensions/realities?
Create a list of snaking numbers under 50,000
GPL Licensed Woocommerce paid plugins
Is it possible for a person to be tricked into becoming a lich?
Storing milk for long periods of time
Necessity of tenure for lifetime academic research
Why do motor drives have multiple bus capacitors of small value capacitance instead of a single bus capacitor of large value?
Find the logic in first 2 statements to give the answer for the third statement
What is this "opened" cube called?
How can I improve my formal definitions
Was a six-engine 747 ever seriously considered by Boeing?
Way to deduce if type is from a templated class
What are POD types in C++?What's the canonical way to check for type in Python?Use 'class' or 'typename' for template parameters?How to determine a Python variable's type?Why can templates only be implemented in the header file?Where and why do I have to put the “template” and “typename” keywords?Why is the C++ STL is so heavily based on templates? (and not on *interfaces*)What are the differences between type() and isinstance()?Explanation of <script type = “text/template”> … </script>Easiest way to convert int to string in C++
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I've been trying to answer the question in the title, but I'm stumped. Basically, trying to see if there's a built-in way to tell the 'source' of a template instantiation, at least for classes. Here is an example of what I'd like to do:
template<class T>
class A ;
auto a = A<int>();
template<class T>
auto someFunction(T item)
if(/* if type of a is from the templated class A */)
// yep A<int> is 'from' A.
Is this possible, in some way such as this? I could use some saved value or inheritance shenanigans to get something similar, but I'd rather not.
c++ templates types
add a comment |
I've been trying to answer the question in the title, but I'm stumped. Basically, trying to see if there's a built-in way to tell the 'source' of a template instantiation, at least for classes. Here is an example of what I'd like to do:
template<class T>
class A ;
auto a = A<int>();
template<class T>
auto someFunction(T item)
if(/* if type of a is from the templated class A */)
// yep A<int> is 'from' A.
Is this possible, in some way such as this? I could use some saved value or inheritance shenanigans to get something similar, but I'd rather not.
c++ templates types
justA<T>, or anyC<Ts...>or alsostd::array<T, N>?
– Jarod42
Mar 27 at 23:01
Do you want to detectstruct Der : A<int>?
– Jarod42
Mar 27 at 23:23
@Jarod42 just anyA<T>s, but nothing else. So, excluding your next two examples.
– AnthonyMonterrosa
Mar 28 at 0:16
add a comment |
I've been trying to answer the question in the title, but I'm stumped. Basically, trying to see if there's a built-in way to tell the 'source' of a template instantiation, at least for classes. Here is an example of what I'd like to do:
template<class T>
class A ;
auto a = A<int>();
template<class T>
auto someFunction(T item)
if(/* if type of a is from the templated class A */)
// yep A<int> is 'from' A.
Is this possible, in some way such as this? I could use some saved value or inheritance shenanigans to get something similar, but I'd rather not.
c++ templates types
I've been trying to answer the question in the title, but I'm stumped. Basically, trying to see if there's a built-in way to tell the 'source' of a template instantiation, at least for classes. Here is an example of what I'd like to do:
template<class T>
class A ;
auto a = A<int>();
template<class T>
auto someFunction(T item)
if(/* if type of a is from the templated class A */)
// yep A<int> is 'from' A.
Is this possible, in some way such as this? I could use some saved value or inheritance shenanigans to get something similar, but I'd rather not.
c++ templates types
c++ templates types
asked Mar 27 at 22:55
AnthonyMonterrosaAnthonyMonterrosa
1339 bronze badges
1339 bronze badges
justA<T>, or anyC<Ts...>or alsostd::array<T, N>?
– Jarod42
Mar 27 at 23:01
Do you want to detectstruct Der : A<int>?
– Jarod42
Mar 27 at 23:23
@Jarod42 just anyA<T>s, but nothing else. So, excluding your next two examples.
– AnthonyMonterrosa
Mar 28 at 0:16
add a comment |
justA<T>, or anyC<Ts...>or alsostd::array<T, N>?
– Jarod42
Mar 27 at 23:01
Do you want to detectstruct Der : A<int>?
– Jarod42
Mar 27 at 23:23
@Jarod42 just anyA<T>s, but nothing else. So, excluding your next two examples.
– AnthonyMonterrosa
Mar 28 at 0:16
just
A<T>, or any C<Ts...> or also std::array<T, N> ?– Jarod42
Mar 27 at 23:01
just
A<T>, or any C<Ts...> or also std::array<T, N> ?– Jarod42
Mar 27 at 23:01
Do you want to detect
struct Der : A<int> ?– Jarod42
Mar 27 at 23:23
Do you want to detect
struct Der : A<int> ?– Jarod42
Mar 27 at 23:23
@Jarod42 just any
A<T>s, but nothing else. So, excluding your next two examples.– AnthonyMonterrosa
Mar 28 at 0:16
@Jarod42 just any
A<T>s, but nothing else. So, excluding your next two examples.– AnthonyMonterrosa
Mar 28 at 0:16
add a comment |
3 Answers
3
active
oldest
votes
Maybe with a custom type traits.
Something as follows
template <typename>
struct is_A : public std::false_type
;
template <typename T>
struct is_A<A<T>> : public std::true_type
;
// ...
template <typename T>
auto someFunction(T item)
if( is_A<T>::value )
// yep A<int> is 'from' A.
Or, maybe, you want intercept non only A<T> but, generically, all types that are a template type, maybe with an undefined number of template arguments?
In this case you can try with something as follows
template <typename>
struct is_template : public std::false_type
;
template <template <typename...> class C, typename ... Ts>
struct is_template<C<Ts...>> : public std::true_type
;
Problem: this type traits intercepts all template types with types template arguments and only template arguments. But doesn't intercept, by example, std::integer_sequence<int, 0, 1, 2, 3, 4, 5> that receive a type and some non-type template parameter.
You can add other specializations for is_template, to intercept other cases, but you can't define a specialization that catch all template types (all combinations of template parameters).
Note that this violates LSP; makeAfinal if you do this.
– Yakk - Adam Nevraumont
Mar 27 at 23:22
@Yakk-AdamNevraumont - ehmmm... sorry, I don't understand what do you mean.
– max66
Mar 27 at 23:27
Ah. en.wikipedia.org/wiki/Liskov_substitution_principle -- that a derived type can be substituted for its parent. IfA<int>is non-final, and B derives fromA<int>, your code will behave differently if passedA<int>thanB. Hence violates LSP.
– Yakk - Adam Nevraumont
Mar 28 at 0:07
@max66 I believe this LSP substitution violation could be solved if the template usedstd::conditionto determine if it inherited fromtrue_typeorfalse_type, instead of using specialization.
– AnthonyMonterrosa
Apr 1 at 8:31
add a comment |
Use a type trait
#include <type_traits>
#include <iostream>
template<class T>
class A ;
auto a = A<int>();
template <typename X>
struct is_from_A : std::false_type ;
template <typename T>
struct is_from_A<A<T>> : std::true_type ;
int main()
std::cout << is_from_A<int>::value << "n"; // 0
std::cout << is_from_A<A<int>>::value << "n"; // 1
Lovely! Thank you. What is the name of the syntax in the linestruct is_from_A<A<T>> : ...? I thought template specializations could only use explicit values, i.e.is_from_A<A<int>> : ..., but apparently this is not the case.
– AnthonyMonterrosa
Mar 28 at 0:20
1
@AnthonyMonterrosa: And so it is partial specialization (not available for function BTW).
– Jarod42
Mar 28 at 2:23
add a comment |
An other way, allowing derived class to match:
template <typename T>
std::true_type is_an_A_impl(A<T>*);
std::false_type is_an_A_impl(...);
template <typename T>
using is_a_A = decltype(is_an_A_impl(std::declval<T*>()));
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55387711%2fway-to-deduce-if-type-is-from-a-templated-class%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Maybe with a custom type traits.
Something as follows
template <typename>
struct is_A : public std::false_type
;
template <typename T>
struct is_A<A<T>> : public std::true_type
;
// ...
template <typename T>
auto someFunction(T item)
if( is_A<T>::value )
// yep A<int> is 'from' A.
Or, maybe, you want intercept non only A<T> but, generically, all types that are a template type, maybe with an undefined number of template arguments?
In this case you can try with something as follows
template <typename>
struct is_template : public std::false_type
;
template <template <typename...> class C, typename ... Ts>
struct is_template<C<Ts...>> : public std::true_type
;
Problem: this type traits intercepts all template types with types template arguments and only template arguments. But doesn't intercept, by example, std::integer_sequence<int, 0, 1, 2, 3, 4, 5> that receive a type and some non-type template parameter.
You can add other specializations for is_template, to intercept other cases, but you can't define a specialization that catch all template types (all combinations of template parameters).
Note that this violates LSP; makeAfinal if you do this.
– Yakk - Adam Nevraumont
Mar 27 at 23:22
@Yakk-AdamNevraumont - ehmmm... sorry, I don't understand what do you mean.
– max66
Mar 27 at 23:27
Ah. en.wikipedia.org/wiki/Liskov_substitution_principle -- that a derived type can be substituted for its parent. IfA<int>is non-final, and B derives fromA<int>, your code will behave differently if passedA<int>thanB. Hence violates LSP.
– Yakk - Adam Nevraumont
Mar 28 at 0:07
@max66 I believe this LSP substitution violation could be solved if the template usedstd::conditionto determine if it inherited fromtrue_typeorfalse_type, instead of using specialization.
– AnthonyMonterrosa
Apr 1 at 8:31
add a comment |
Maybe with a custom type traits.
Something as follows
template <typename>
struct is_A : public std::false_type
;
template <typename T>
struct is_A<A<T>> : public std::true_type
;
// ...
template <typename T>
auto someFunction(T item)
if( is_A<T>::value )
// yep A<int> is 'from' A.
Or, maybe, you want intercept non only A<T> but, generically, all types that are a template type, maybe with an undefined number of template arguments?
In this case you can try with something as follows
template <typename>
struct is_template : public std::false_type
;
template <template <typename...> class C, typename ... Ts>
struct is_template<C<Ts...>> : public std::true_type
;
Problem: this type traits intercepts all template types with types template arguments and only template arguments. But doesn't intercept, by example, std::integer_sequence<int, 0, 1, 2, 3, 4, 5> that receive a type and some non-type template parameter.
You can add other specializations for is_template, to intercept other cases, but you can't define a specialization that catch all template types (all combinations of template parameters).
Note that this violates LSP; makeAfinal if you do this.
– Yakk - Adam Nevraumont
Mar 27 at 23:22
@Yakk-AdamNevraumont - ehmmm... sorry, I don't understand what do you mean.
– max66
Mar 27 at 23:27
Ah. en.wikipedia.org/wiki/Liskov_substitution_principle -- that a derived type can be substituted for its parent. IfA<int>is non-final, and B derives fromA<int>, your code will behave differently if passedA<int>thanB. Hence violates LSP.
– Yakk - Adam Nevraumont
Mar 28 at 0:07
@max66 I believe this LSP substitution violation could be solved if the template usedstd::conditionto determine if it inherited fromtrue_typeorfalse_type, instead of using specialization.
– AnthonyMonterrosa
Apr 1 at 8:31
add a comment |
Maybe with a custom type traits.
Something as follows
template <typename>
struct is_A : public std::false_type
;
template <typename T>
struct is_A<A<T>> : public std::true_type
;
// ...
template <typename T>
auto someFunction(T item)
if( is_A<T>::value )
// yep A<int> is 'from' A.
Or, maybe, you want intercept non only A<T> but, generically, all types that are a template type, maybe with an undefined number of template arguments?
In this case you can try with something as follows
template <typename>
struct is_template : public std::false_type
;
template <template <typename...> class C, typename ... Ts>
struct is_template<C<Ts...>> : public std::true_type
;
Problem: this type traits intercepts all template types with types template arguments and only template arguments. But doesn't intercept, by example, std::integer_sequence<int, 0, 1, 2, 3, 4, 5> that receive a type and some non-type template parameter.
You can add other specializations for is_template, to intercept other cases, but you can't define a specialization that catch all template types (all combinations of template parameters).
Maybe with a custom type traits.
Something as follows
template <typename>
struct is_A : public std::false_type
;
template <typename T>
struct is_A<A<T>> : public std::true_type
;
// ...
template <typename T>
auto someFunction(T item)
if( is_A<T>::value )
// yep A<int> is 'from' A.
Or, maybe, you want intercept non only A<T> but, generically, all types that are a template type, maybe with an undefined number of template arguments?
In this case you can try with something as follows
template <typename>
struct is_template : public std::false_type
;
template <template <typename...> class C, typename ... Ts>
struct is_template<C<Ts...>> : public std::true_type
;
Problem: this type traits intercepts all template types with types template arguments and only template arguments. But doesn't intercept, by example, std::integer_sequence<int, 0, 1, 2, 3, 4, 5> that receive a type and some non-type template parameter.
You can add other specializations for is_template, to intercept other cases, but you can't define a specialization that catch all template types (all combinations of template parameters).
edited Mar 27 at 23:08
answered Mar 27 at 23:01
max66max66
45.3k7 gold badges48 silver badges80 bronze badges
45.3k7 gold badges48 silver badges80 bronze badges
Note that this violates LSP; makeAfinal if you do this.
– Yakk - Adam Nevraumont
Mar 27 at 23:22
@Yakk-AdamNevraumont - ehmmm... sorry, I don't understand what do you mean.
– max66
Mar 27 at 23:27
Ah. en.wikipedia.org/wiki/Liskov_substitution_principle -- that a derived type can be substituted for its parent. IfA<int>is non-final, and B derives fromA<int>, your code will behave differently if passedA<int>thanB. Hence violates LSP.
– Yakk - Adam Nevraumont
Mar 28 at 0:07
@max66 I believe this LSP substitution violation could be solved if the template usedstd::conditionto determine if it inherited fromtrue_typeorfalse_type, instead of using specialization.
– AnthonyMonterrosa
Apr 1 at 8:31
add a comment |
Note that this violates LSP; makeAfinal if you do this.
– Yakk - Adam Nevraumont
Mar 27 at 23:22
@Yakk-AdamNevraumont - ehmmm... sorry, I don't understand what do you mean.
– max66
Mar 27 at 23:27
Ah. en.wikipedia.org/wiki/Liskov_substitution_principle -- that a derived type can be substituted for its parent. IfA<int>is non-final, and B derives fromA<int>, your code will behave differently if passedA<int>thanB. Hence violates LSP.
– Yakk - Adam Nevraumont
Mar 28 at 0:07
@max66 I believe this LSP substitution violation could be solved if the template usedstd::conditionto determine if it inherited fromtrue_typeorfalse_type, instead of using specialization.
– AnthonyMonterrosa
Apr 1 at 8:31
Note that this violates LSP; make
A final if you do this.– Yakk - Adam Nevraumont
Mar 27 at 23:22
Note that this violates LSP; make
A final if you do this.– Yakk - Adam Nevraumont
Mar 27 at 23:22
@Yakk-AdamNevraumont - ehmmm... sorry, I don't understand what do you mean.
– max66
Mar 27 at 23:27
@Yakk-AdamNevraumont - ehmmm... sorry, I don't understand what do you mean.
– max66
Mar 27 at 23:27
Ah. en.wikipedia.org/wiki/Liskov_substitution_principle -- that a derived type can be substituted for its parent. If
A<int> is non-final, and B derives from A<int>, your code will behave differently if passed A<int> than B. Hence violates LSP.– Yakk - Adam Nevraumont
Mar 28 at 0:07
Ah. en.wikipedia.org/wiki/Liskov_substitution_principle -- that a derived type can be substituted for its parent. If
A<int> is non-final, and B derives from A<int>, your code will behave differently if passed A<int> than B. Hence violates LSP.– Yakk - Adam Nevraumont
Mar 28 at 0:07
@max66 I believe this LSP substitution violation could be solved if the template used
std::condition to determine if it inherited from true_type or false_type, instead of using specialization.– AnthonyMonterrosa
Apr 1 at 8:31
@max66 I believe this LSP substitution violation could be solved if the template used
std::condition to determine if it inherited from true_type or false_type, instead of using specialization.– AnthonyMonterrosa
Apr 1 at 8:31
add a comment |
Use a type trait
#include <type_traits>
#include <iostream>
template<class T>
class A ;
auto a = A<int>();
template <typename X>
struct is_from_A : std::false_type ;
template <typename T>
struct is_from_A<A<T>> : std::true_type ;
int main()
std::cout << is_from_A<int>::value << "n"; // 0
std::cout << is_from_A<A<int>>::value << "n"; // 1
Lovely! Thank you. What is the name of the syntax in the linestruct is_from_A<A<T>> : ...? I thought template specializations could only use explicit values, i.e.is_from_A<A<int>> : ..., but apparently this is not the case.
– AnthonyMonterrosa
Mar 28 at 0:20
1
@AnthonyMonterrosa: And so it is partial specialization (not available for function BTW).
– Jarod42
Mar 28 at 2:23
add a comment |
Use a type trait
#include <type_traits>
#include <iostream>
template<class T>
class A ;
auto a = A<int>();
template <typename X>
struct is_from_A : std::false_type ;
template <typename T>
struct is_from_A<A<T>> : std::true_type ;
int main()
std::cout << is_from_A<int>::value << "n"; // 0
std::cout << is_from_A<A<int>>::value << "n"; // 1
Lovely! Thank you. What is the name of the syntax in the linestruct is_from_A<A<T>> : ...? I thought template specializations could only use explicit values, i.e.is_from_A<A<int>> : ..., but apparently this is not the case.
– AnthonyMonterrosa
Mar 28 at 0:20
1
@AnthonyMonterrosa: And so it is partial specialization (not available for function BTW).
– Jarod42
Mar 28 at 2:23
add a comment |
Use a type trait
#include <type_traits>
#include <iostream>
template<class T>
class A ;
auto a = A<int>();
template <typename X>
struct is_from_A : std::false_type ;
template <typename T>
struct is_from_A<A<T>> : std::true_type ;
int main()
std::cout << is_from_A<int>::value << "n"; // 0
std::cout << is_from_A<A<int>>::value << "n"; // 1
Use a type trait
#include <type_traits>
#include <iostream>
template<class T>
class A ;
auto a = A<int>();
template <typename X>
struct is_from_A : std::false_type ;
template <typename T>
struct is_from_A<A<T>> : std::true_type ;
int main()
std::cout << is_from_A<int>::value << "n"; // 0
std::cout << is_from_A<A<int>>::value << "n"; // 1
answered Mar 27 at 23:07
formerlyknownas_463035818formerlyknownas_463035818
24.1k4 gold badges32 silver badges81 bronze badges
24.1k4 gold badges32 silver badges81 bronze badges
Lovely! Thank you. What is the name of the syntax in the linestruct is_from_A<A<T>> : ...? I thought template specializations could only use explicit values, i.e.is_from_A<A<int>> : ..., but apparently this is not the case.
– AnthonyMonterrosa
Mar 28 at 0:20
1
@AnthonyMonterrosa: And so it is partial specialization (not available for function BTW).
– Jarod42
Mar 28 at 2:23
add a comment |
Lovely! Thank you. What is the name of the syntax in the linestruct is_from_A<A<T>> : ...? I thought template specializations could only use explicit values, i.e.is_from_A<A<int>> : ..., but apparently this is not the case.
– AnthonyMonterrosa
Mar 28 at 0:20
1
@AnthonyMonterrosa: And so it is partial specialization (not available for function BTW).
– Jarod42
Mar 28 at 2:23
Lovely! Thank you. What is the name of the syntax in the line
struct is_from_A<A<T>> : ...? I thought template specializations could only use explicit values, i.e. is_from_A<A<int>> : ..., but apparently this is not the case.– AnthonyMonterrosa
Mar 28 at 0:20
Lovely! Thank you. What is the name of the syntax in the line
struct is_from_A<A<T>> : ...? I thought template specializations could only use explicit values, i.e. is_from_A<A<int>> : ..., but apparently this is not the case.– AnthonyMonterrosa
Mar 28 at 0:20
1
1
@AnthonyMonterrosa: And so it is partial specialization (not available for function BTW).
– Jarod42
Mar 28 at 2:23
@AnthonyMonterrosa: And so it is partial specialization (not available for function BTW).
– Jarod42
Mar 28 at 2:23
add a comment |
An other way, allowing derived class to match:
template <typename T>
std::true_type is_an_A_impl(A<T>*);
std::false_type is_an_A_impl(...);
template <typename T>
using is_a_A = decltype(is_an_A_impl(std::declval<T*>()));
add a comment |
An other way, allowing derived class to match:
template <typename T>
std::true_type is_an_A_impl(A<T>*);
std::false_type is_an_A_impl(...);
template <typename T>
using is_a_A = decltype(is_an_A_impl(std::declval<T*>()));
add a comment |
An other way, allowing derived class to match:
template <typename T>
std::true_type is_an_A_impl(A<T>*);
std::false_type is_an_A_impl(...);
template <typename T>
using is_a_A = decltype(is_an_A_impl(std::declval<T*>()));
An other way, allowing derived class to match:
template <typename T>
std::true_type is_an_A_impl(A<T>*);
std::false_type is_an_A_impl(...);
template <typename T>
using is_a_A = decltype(is_an_A_impl(std::declval<T*>()));
answered Mar 28 at 1:20
Jarod42Jarod42
130k12 gold badges115 silver badges203 bronze badges
130k12 gold badges115 silver badges203 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55387711%2fway-to-deduce-if-type-is-from-a-templated-class%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
just
A<T>, or anyC<Ts...>or alsostd::array<T, N>?– Jarod42
Mar 27 at 23:01
Do you want to detect
struct Der : A<int>?– Jarod42
Mar 27 at 23:23
@Jarod42 just any
A<T>s, but nothing else. So, excluding your next two examples.– AnthonyMonterrosa
Mar 28 at 0:16