C++

The C++ badge, lettered “Power Without Limits · Handle with care” round its band
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

Try it in the playground →

Versions

Ur reads C++ as the profiles below name it. Name the versions a project targets in target; without it, Ur reads cpp-17.

ProfileDialect
cpp-98GNU
cpp-11GNU
cpp-14GNU
cpp-17GNU
cpp-20GNU
cpp-23GNU