cppinsights icon indicating copy to clipboard operation
cppinsights copied to clipboard

does cppinsights support multiple file parsing

Open sshsu opened this issue 3 years ago • 2 comments

I try to make a test using two files as below

// b.h

#ifndef B_H_
#define B_H_

template<typename T>
T Add(T t1, T t2){
  T result = t1 + t2;  
}

#endif 
//main.cpp

#include<iostream>
#include "b.h"

int main(){

    int t1 =1;
    int t2 =2;
    int result = Add<int>(t1, t2);
    std::cout<<result;
    return 0;
}

then I use c++insights in vscode, it doesn't show the template deduction. Does c++insight support it?

image

sshsu avatar Jan 02 '22 07:01 sshsu

Hello @sshsu,

thanks for bringing this up! C++ Insights blocks transformations from include files for two reasons:

  1. Usually the expansion of STL headers is more confusing then helpful.
  2. For own include files, as well as for STL includes, I need a location where to insert the transformation.

I can look into this and see what I can do. One idea is to insert the transformations from include files directly below the #include.

Please let me know what you think.

Andreas

andreasfertig avatar Jan 04 '22 09:01 andreasfertig

FYI, what I'm doing in @jacquev6/Sudoku (see commit referenced just above this comment) :

In that project, I git add the outputs of C++ Insights, so that git diff gives me insights on what I've changed. With that setup, I wanted to validate that a refactoring in a template did what I expected. That template is defined in a header file in my project, so I faced this issue : the template instanciation was not in the insight.

So I decided to write a very crude C preprocessor that only includes local files, and to pass its output to insights. Worked like a charm, and I was able to validate my refactoring in the next commit.

jacquev6 avatar Nov 24 '23 17:11 jacquev6