better-cpp-syntax
better-cpp-syntax copied to clipboard
template template parameter does not colorized correctly
ITNOA
where is "C_Cpp.enhancedColorization": "Disabled" ? ---> I don't find place of this configuration.
The code with a problem is:
Describe the bug
- OS and Version: Windows 10 21H1
- VS Code Version: 1.60.2
- C/C++ Extension Version: 1.6.0
- Other extensions you installed (and if the issue persists after disabling them):
- If using SSH remote, specify OS of remote machine: I have using WSL 1 with Ubuntu 20.04.2 with GCC-11
- A clear and concise description of what the bug is, including information about the workspace (i.e. is the workspace a single project or multiple projects, size of the project, etc).
I have single file that name is main.cpp
and having something code
template <template <typename> class List, typename I>
void foo(std::function<I(I), const List<I>& list);
the problem is template inside of template is not colorized.
Expected behavior
I except internal template make colorized like external template keyword.
Code sample and logs
- Code sample
#include <cstdlib>
#include <cstddef>
#include <cmath>
#include <iostream>
#include <thread>
#include <functional>
#include <new>
#include <algorithm>
#include <iterator>
#include <chrono>
#include <vector>
#include <random>
#include <ranges>
using namespace std;
#ifdef __cpp_lib_hardware_interference_size
using std::hardware_destructive_interference_size;
#else
constexpr std::size_t hardware_destructive_interference_size = 2 * alignof(std::max_align_t);
#endif
struct NativeInt
{
int value;
};
static_assert(alignof(NativeInt) < hardware_destructive_interference_size);
struct CacheInt
{
alignas(hardware_destructive_interference_size) int value;
};
static_assert(alignof(CacheInt) >= hardware_destructive_interference_size);
void hello_world() noexcept
{
cout << "salam" << endl;
}
template <typename T>
T my_sqrt(T value)
{
return std::sqrt(value);
}
template <template <class I> class List, typename I, typename ElementType>
auto sqrt_function(std::function<I(I)> sqrt_func, const List<I>& elements) -> std::vector<ElementType>
{
std::vector<ElementType> results;
std::transform(elements.cbegin(), elements.cend(), std::back_inserter(results), sqrt_func);
return results;
}
std::mutex global_mutex;
void change_data(std::vector<int>& data)
{
std::lock_guard<std::mutex> lock{global_mutex};
const unsigned int seed = std::chrono::system_clock::now().time_since_epoch().count();
std::ranges::shuffle(data, std::default_random_engine(seed));
}
int main()
{
std::thread my_thread(hello_world);
std::vector<int> data(30);
std::iota(data.begin(), data.end(), 0);
std::thread et1(change_data, std::ref(data));
std::thread et2(change_data, std::ref(data));
et1.join();
et2.join();
cout << "result of working parrallel on data: " << endl;
std::copy(data.cbegin(), data.cend(), std::ostream_iterator<double>(std::cout, ", "));
std::cout << std::endl;
cout << "hardware concurrency: " << std::thread::hardware_concurrency() << endl;
cout << "native int alignment: " << alignof(NativeInt) << endl;
cout << "cache int alignement: " << alignof(CacheInt) << endl;
cout << std::boolalpha << std::hash<std::thread::id>{}(my_thread.get_id()) << endl;
my_thread.join();
std::vector<double> results = sqrt_function<std::vector, float, double>(my_sqrt<float>, std::vector<float>(10, 9.f));
std::copy(results.cbegin(), results.cend(), std::ostream_iterator<double>(std::cout, ", "));
return EXIT_SUCCESS;
}
- Configurations in
c_cpp_properties.json
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/g++-11",
"cStandard": "gnu17",
"cppStandard": "gnu++20",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
Screenshots

related to https://github.com/microsoft/vscode-cpptools/issues/8238
related to #246
I believe this is fixed now
