-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
not support angle brackets for c++.png #77
Comments
Hi,
|
Hello, template <typename... Args> the angle brackets are used to surround the type args of the template and not the simple 'Operator' as you might think, and implementing it might require much effort if you're not familiar with C++ . Maybe you can create a 'develop' branch, and I would be happy to test it. Hopefully, the following code and its comments can provide assistance to your development: #include <functional>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;
//template class or template func has 'template <...>'('...' are type Args of the template) above.
template <typename T> //args of the template arg surrounded with angle brackets
class TClass
{
T value_;
public:
TClass(T value)
{
value_ = value;
}
friend ostream& operator<<(ostream& os, const TClass& t_class)
{
os << t_class.value_ << endl;
return os;
}
};
template <typename T> //args of the template arg surrounded with angle brackets
void TFunc(T arg)
{
//'<<','>>'is stream operator here;
stringstream ss;
ss << arg;
string result;
ss >> result;
cout << "result is " << result << endl;
}
template <typename... Ts>
using a2t = tuple<Ts...>; //tuple is a template class of the STL
using namespace std;
class Async
{
//shared_ptr is a template class
shared_ptr<bool> p_is_finish_ = make_shared<bool>(false);
public:
//here are 4 template func,there arg a constructor.
//`enable_if_t`,`is_invocable_v`,`is_convertible_v`,`invoke_result_t` are template func
template <typename Ret, typename Func, typename... Args,
typename = enable_if_t<is_invocable_v<Func, Args...> &&
(is_convertible_v<invoke_result_t<Func, Args...>, Ret> || is_same_v<Ret, nullptr_t>)>>
Async(Ret&& ret, Func&& func, tuple<Args...>&& args); //tuple is a template class of the STL
template <typename Func, typename... Args>
Async(Func&& func, tuple<Args...>&& args);
template <typename Ret, typename Func, typename... Args,
typename = enable_if_t<is_invocable_v<Func, Args...> &&
(is_convertible_v<invoke_result_t<Func, Args...>, Ret> || is_same_v<Ret, nullptr_t>)>>
Async(Ret&& ret, Func&& func, tuple<Args...>&& args,
const double max_exe_secs, const function<void()> post_process = nullptr);
//function is a template class of the STL
template <typename Func, typename... Args>
Async(Func&& func, tuple<Args...>&& args, const double max_exe_secs,
const function<void()> post_process = nullptr);
};
int main()
{
//briefly,when "template",class, func are follow with '<>' and with many type split with ',' in '<>',it can be inferred that '<>' are used to surround the type Args.
//When variables or literal are follow with '<' or '>',if can be inferred that '<' or '>' are simple operator.
TClass<double> t_class(0);
TFunc(1); //T as the type of the arg of the TFunc can be automatically deduced to int here,
TFunc<double>(1); //manually specify T is double
//equally
TFunc <double> (1); //manually specify T is double
Async async<void, void(*)(int), tuple<int>>(async, a2t(1));
//vector is a template class need template arg which surrounded with angle brackets like TClass
std::vector<std::vector<int>> matrix{{0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}};
std::vector<std::vector<std::vector<int>>> cubic{
{{0, 1}, {1}, {2}},
{{0, 1}, {1}, {2}},
{{0, 1}, {1}, {2}}
};
//'<'and'>' as operator
if (1 < 2 && 2 > 3);
return 0;
} |
I see, I did some rework based on classifications of next and previous tags. The supplied file looks good to me, but I see some errors, maybe some library is missing or what. :D When Mad merges it, you can try. That feature maybe help. But I don't know how to invoke it, whether I can invoke it safely (without interference to GUI) and I'm not sure it will don't incur some performace hit (can be implemented to full scan whole file for every single pair). But I'll keep it in mind if my previous solution will fail unrecoverably. |
ok. I cannot wait to try it. |
Good job, you kill a bug.But you make another bug, and there is still a bug waiting to be killed. |
@1821746019 Is it better now? |
I got it. It must be the bug of vs.In addition, I see that you test the code I provided above by yourself. Please ignore the
|
Now the extension behaves fine. If I find any other bugs, I'll report them. Thank you. |
@lordfanger |
Is ' |
In |
Thank you for reports. |
for (int i = 0; i < ui->listWidget_dll_paths->count(); ++i)
{
if (i < ui->listWidget_dll_paths->count())
{
}
auto item = ui->listWidget_dll_paths->item(i);
if (item->data(Qt::UserRole).toString() == file_path)
{
result = true;
break;
}
} #include <windows.h>
#include <detours.h>
#include <unordered_map>
#include <fstream>
#include <string>
using namespace std;
export
{
class Hooker
{
unordered_map<PVOID*, PVOID> hook_map_;
Hooker(const unordered_map<PVOID*, PVOID>& hook_map = {}): hook_map_((hook_map))
{
}
public:
static Hooker& instance()
{
static Hooker hooker;
return hooker;
}
void setHook()
{
consolePrint("setting hook\n");
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
for (auto& e : hook_map_)
{
DetourAttach(e.first, e.second);
}
DetourTransactionCommit();
consolePrint("finished setting hook\n");
}
void unHook()
{
consolePrint("start to RemoveHook\n");
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
for (auto& e : hook_map_)
{
DetourDetach((LPVOID*)&e.first, e.second);
}
DetourTransactionCommit();
consolePrint("RemoveHook finish.\n");
}
};
}
template <typename T>
concept StringOrWString = std::is_same_v<T, std::string> || std::is_same_v<T, std::wstring>;
template <StringOrWString T>
T NewPath(const T& raw)
{
T ret;
vector<int> tmp;
// TO DO:
return ret;
} |
Thank you, |
I am suspecting if the bugs of the experimental C++20 module feature in Visual Studio are causing the angle bracket to be uncolorized.no use of c++20 moduleimport essential module.I also add whitespace to avoid the influences of cache. I am not using modules in this file, so it might be the bugs of the extension. |
But you will not see the bugs if you do not import modules. The IntelliSense for C++20 module of VS is immature and often makes my variables colorized abnormally, so I tend to think it is the fault of VS. |
|
I know about that. Sometimes it happens, I'm not sure why, but I'll have to rewrite a lot of the code. Refresh the colors should work or close/reopen file should work. |
Describe the bug
not support colorizing angle brackets for c++,but xml is supported
To Reproduce
Steps to reproduce the behavior:
1.create a .h/.cpp/.ixx/.cppm file.
2.paste:
Expected behavior



colorizing any angle bracket normally.
Screenshots
Additional context
I am eager to see this bug repaired.It is uncomfortable to see the bracket with no color.
Waiting for your good news
The text was updated successfully, but these errors were encountered: