Formatter: lines with "typeid()" formats wrong line wraps [message #1837233] |
Mon, 25 January 2021 16:04 |
Mikkel Holch Messages: 2 Registered: January 2021 Location: Denmark |
Junior Member |
|
|
Hello All..
Where do i get it wrong, i tried all the build in formatting styles but they all fail, The IDE is from ST, called STM32CubeIDE, based on Eclipse CDT 9.11
if i change typeid() -> typoid() , if formats correct
aka. Resulting in changing the "typeid keyword" -> "typoid function"
The code shold compile and run correct.
http://cpp.sh/2vnbe
/*
* test1.cpp
*/
#include <map>
#include <vector>
#include <string>
#include <typeinfo>
#include <typeindex>
#include <iostream>
using std::map;
using std::vector;
using std::string;
using std::type_index;
using std::cout;
template<class T>
type_index typoid(T)
{
return typeid(T);
}
int main()
{
map<type_index, vector<string>> myTypeMap;
myTypeMap[typeid(int)].push_back("this ");
myTypeMap[typeid(int)].push_back("is a ");
myTypeMap[typeid(int)].push_back("int\r\n");
myTypeMap[typeid(float)].push_back("this ");
myTypeMap[typeid(float)].push_back("must be a ");
myTypeMap[typeid(float)].push_back("float\r\n");
float f;
for (auto output : myTypeMap[typoid(f)])
{
cout << output;
}
int i;
for (auto output : myTypeMap[typeid(i)])
{
cout << output;
}
return 0;
}
but formatting it results in
/*
* test1.cpp
*/
#include <map>
#include <vector>
#include <string>
#include <typeinfo>
#include <typeindex>
#include <iostream>
using std::map;
using std::vector;
using std::string;
using std::type_index;
using std::cout;
template<class T>
type_index typoid(T)
{
return typeid(T);
}
int main()
{
map<type_index, vector<string>> myTypeMap;
myTypeMap[typeid(int)].push_back("this ");
myTypeMap[typeid(int)].push_back("is a ");
myTypeMap[typeid(int)].push_back("int\r\n");
myTypeMap[typeid(float)].push_back("this ");
myTypeMap[typeid(float)].push_back("must be a ");
myTypeMap[typeid(float)].push_back("float\r\n");
float f;
for (auto output : myTypeMap[typoid(f)])
{
cout << output;
}
int i;
for (auto output : myTypeMap[typeid (i)])
{
cout << output;
}
return 0;
}
Any clue anyone ?
Or is it only on my setup ??
/M
[Updated on: Mon, 25 January 2021 16:13] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03634 seconds