I've seen both of them a lot when defining templates, what's the difference between these two?
And the other question is, I saw a template like this on Wikipedia What does each keyword mean here?
template < template < typename, typename > class Container, typename Type >
class Example
{
Container< Type, std::allocator < Type > > baz;
};
Usually, you can use either typename
or class
.
template<class T>
class Foo{};
///Two are the same
template<typename T>
class Foo{};
Special cases where the two cannot be mixed
If you are writing types related to other template parameters, you can only write the typename
keyword.
template<typename param_t>
class Foo
{
typedef typename param_t::baz sub_t;
};
The second question is here.
template template
must use the class
keyword as follows, and cannot be mixed with typename
at this time
template < template < typename, typename > class Container, typename Type >
In addition, when instantiating a template, you can only write class
as follows:
template class Foo<int>;
865 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
564 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
592 GDB gets version error when attempting to debug with the Presense SDK (IDE)
566 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.