-
Notifications
You must be signed in to change notification settings - Fork 30
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
Template definition needs multiple fixes #246
Comments
Next thing on my list is to rewrite the template definition syntax from scratch. I agree it should be change, to be honest though, I don't know the meanings/use-case of the more complicated options. I can't even really tell the difference between After this next change, I think all the template definition issues will be permanently solved. |
typename and class are identical when used inside a template definition |
Ignoring C++20 (concepts) for simplicity. type parameter:Probably the most common, has the form of
non type parameter:This is used when you want to template on some compile time value. See std::array. These have the form of template paramatersUsed when you want your type paramter to itself be a template. Basically a nested template definition followed by a type paramater.
paramteer packsAdds |
I'm going to turn this into a major issue and close the other ones since they're related and are going to be fixed all at once Official Syntax:
This is the next major task on the todo list |
storage.type
should be reserved for typename
and class
Just as an FYI, I added |
Posting as this example shows many of the previously mentioned issues with templates. Example: template <class U,
class = std::enable_if_t<std::is_constructible_v<T, U &&> &&
std::is_convertible_v<U &&, T>>>
constexpr propagate_const(propagate_const<U> &&pu) {} On line 2 you can see keywords with no highlighting. |
Test cases: template<> // empty template
template<class> // unnamed parameter
template<typename>
template<class T> // named parameter
template<size_t I> // non-type parameter
template<class =void> // defaulted type parameter
template<size_t = 0> // defaulted non type parameter
template<class T, size_t I, class A = my::allocator<T, I>> // complex template
template<class...> // unnamed param-pack
template<size_t...> // unnamed non-type param-pack
template<class A, class...B> // named param pack
template<class A, template<class B> class C = std::deque<A>> // template template |
2 more test cases for my issue:
|
Not entirely sure if this is a duplicate of #106, but in the following example.
Typename
(note the capitalization) has the scopestorage.type.template.argument.Typename.cpp
The use ofstorage.type
causes many themes to colorTypename
the same as a keyword. This can cause people to incorrectly believe that they are creating a standard type template, when in fact they are creating a non-type template.The text was updated successfully, but these errors were encountered: