C++

- Files
.cpp.cc.cxx.c++.hpp.hh.hxx.h++.ipp.tpp.inl.cppm.ixx.ccm.cxxm.c++m- Formats as
- clang-format
- Lints
- Every rule that reads its code
- In
ur.toml [format.cpp]
Formatted
cart.cpp, as written#include <vector>
// What a cart costs.
namespace cart {
struct Item { int price; int quantity; };
int subtotal(const std::vector<Item> & items){
int sum=0;
for(const Item & item:items) sum+=item.price*item.quantity;
return sum;
}
} // namespace cart
ur format --style clang-format cart.cpp#include <vector>
// What a cart costs.
namespace cart {
struct Item {
int price;
int quantity;
};
int subtotal(const std::vector<Item> &items) {
int sum = 0;
for (const Item &item : items)
sum += item.price * item.quantity;
return sum;
}
} // namespace cart
Versions
Ur reads C++ as the profiles below name it. Name the versions a project targets in target; without it, Ur reads cpp-17.
| Profile | Dialect |
|---|---|
cpp-98 | GNU |
cpp-11 | GNU |
cpp-14 | GNU |
cpp-17 | GNU |
cpp-20 | GNU |
cpp-23 | GNU |