C++ Code Support Documentation

This document explains the supported features and limitations of the C++ language on the current platform.
Please adhere to the following rules to avoid using incompatible syntax features.

Supported Features

1. Basic Data Types

The following basic types are supported for declaration and usage:
char, string, bool, int, float, double

Example:

2. Standard Containers

The following containers and their nested forms are supported:

Container TypeExample
vector<T>vector<int> nums3
vector<vector<T>>2D dynamic array
map<T1, T2>map<int, string>
unordered_map<T1,T2>Hash table
queue<T>Queue
set<T>Set
unordered_set<T>Set
stack<T>Stack

Constraints:

  • Keys in map/unordered_map must be basic types (char/string/bool/int/float/double).
  • Container nesting depth is limited to 2 levels (e.g., vector<vector<int>>).

3. Built-in Data Structures

The following predefined structures can be directly used:

4. Language Features

  • Code must include a main function with an int return type and explicitly return an int.
  • Supported: Functions and class methods (excluding static class methods).
  • Supported: Lambda expressions, but variables must be explicitly captured (e.g., [&]{}).
  • Common headers (e.g., <vector>, <algorithm>) are pre-included; no manual inclusion is needed.
  #include <algorithm>
  #include <bitset>
  #include <cmath>
  #include <deque>
  #include <map>
  #include <numeric>
  #include <queue>
  #include <random>
  #include <set>
  #include <stack>
  #include <string>
  #include <unordered_map>
  #include <unordered_set>
  #include <vector>
  #include <utility>

Limitations and Notes

Unsupported Syntax

CategoryExampleRemarks
Header Inclusion#include <sstream>Common libraries are pre-included
Static MethodsMyClass::staticFunc()Static class methods are unsupported
Anonymous Lambdas (without &)[](){ ... }Must use explicit capture like [&](){ ... }
stringstreamss << "text"Use alternatives like to_string
In-function Structsvoid func() { struct X }Structs must be defined globally or within a class

Other Restrictions

  1. Incomplete class support; prioritize standalone functions or class methods.
  2. Avoid complex templates; custom template classes may fail to parse.
  3. Non-basic types as map keys are unsupported. Example of invalid code:

Code Examples


Adjust your code according to the above rules. Contact platform support if issues arise.