template class with .inl logic

How can I create and implement a template class with *.inl implementation in c++ using vs 2019? I also need the steps to compile it as well.
I am trying to create .INL file type in VS 2019, but can see only builtin C/C++ extensions. Is there any other way to create it?

I need to include template class with template implementation in .INL file.
Something like this:

//InlSampleTest.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#ifndef INLSAMPLE_TEST_H
#define INLSAMPLE_TEST_H

struct InlSampleTest {

void foo(const int& inFoo);

template <typename T>
void bar(const T& inBar);

};

#include "InlSampleTest.inl"
#endif // INLSAMPLE_TEST_H



//InlSampleTest.inl

1
2
3
4
5
6
7
8
9
10
11
12

#include "InlSampleTest.h"  //needed for intellisense sometimes

#include <iostream>
template <typename T>
void InlSampleTest::bar(const T& inBar);
{
   std::cout<< inBar << std::endl;
}







I am trying to create .INL file type in VS 2019, but can see only builtin C/C++ extensions.
What does 'see' mean? You need to add the .inl file to your project like any other .cpp or .h file.
Last edited on
While in VS2019, after I click Add->New item, I see only the below options.
Where can I find .inl?

C++ file (.cpp)
Header file (.h)
C++ class
C++ Module interface unit (.ixx)


How can I create and implement a template class with *.inl implementation in c++ using vs 2019?

And

I am trying to create .INL file type in VS 2019, but can see only builtin C/C++ extensions.

Simply rename the extension. Header files by themselves aren't directly compileable so the extension is really only for us hoo-mans.

I routinely use .hpp header files instead of .h when creating C++ code. When creating a new file to add to the current project/solution I use one of the available built-in types and change the name. Including the extension.

I'm lazy enough I select the first available file type (.cpp) and change the name and extension to whatever I want before VS creates the file.

You can rename a file that is already in the project/solution list as well. The Solution Explorer view of where your project's files are sorted can be manually changed. Drag and drop.

This isn't rocket science after all.
Ok understood, thanks to clarify.
Topic archived. No new replies allowed.