long| General topics | ||||||||||||||||
| Flow control | ||||||||||||||||
| Conditional execution statements | ||||||||||||||||
| Iteration statements (loops) | ||||||||||||||||
| Jump statements | ||||||||||||||||
| Functions | ||||||||||||||||
| Function declaration | ||||||||||||||||
| Lambda function expression | ||||||||||||||||
inline specifier | ||||||||||||||||
| Dynamic exception specifications(until C++17*) | ||||||||||||||||
noexcept specifier(C++11) | ||||||||||||||||
| Exceptions | ||||||||||||||||
| Namespaces | ||||||||||||||||
| Types | ||||||||||||||||
| Specifiers | ||||||||||||||||
| ||||||||||||||||
| Storage duration specifiers | ||||||||||||||||
| Initialization | ||||||||||||||||
| Expressions | ||||||||||||||||
| Alternative representations | ||||||||||||||||
| Literals | ||||||||||||||||
| Boolean -Integer -Floating-point | ||||||||||||||||
| Character -String -nullptr(C++11) | ||||||||||||||||
| User-defined(C++11) | ||||||||||||||||
| Utilities | ||||||||||||||||
| Attributes(C++11) | ||||||||||||||||
| Types | ||||||||||||||||
typedef declaration | ||||||||||||||||
| Type alias declaration(C++11) | ||||||||||||||||
| Casts | ||||||||||||||||
| Memory allocation | ||||||||||||||||
| Classes | ||||||||||||||||
| Class-specific function properties | ||||||||||||||||
| ||||||||||||||||
| Special member functions | ||||||||||||||||
| Templates | ||||||||||||||||
| Miscellaneous | ||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Identifiers with special meaning | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#include <climits>#include <concepts>#include <iostream>#include <limits>#include <locale> static_assert( sizeof(long)>=32/CHAR_BIT&& sizeof(unsignedlong)>=32/CHAR_BIT&&std::numeric_limits<long>::min()<=-2'147'483'647l - 1 && //'std::numeric_limits<long>::max()>=2'147'483'647l && //'std::numeric_limits<unsignedlong>::max()>=4'294'967'295ul); //' // 'long long' and 'unsigned long long' are available since C++11static_assert( sizeof(longlong)>=64/CHAR_BIT&& sizeof(unsignedlonglong)>=64/CHAR_BIT&&std::numeric_limits<longlong>::min()<=-9'223'372'036'854'775'807ll-1&&std::numeric_limits<longlong>::max()>=9'223'372'036'854'775'807ll&&std::numeric_limits<unsignedlonglong>::max()>=18'446'744'073'709'551'615ull); // concepts are available since C++20static_assert(std::integral<long>&&std::integral<longlong>&&std::integral<unsignedlong>&&std::integral<unsignedlonglong>&&std::floating_point<longdouble>);// Note that 'long' cannot modify 'float' static_assert(std::same_as<decltype(0l),signedlongint>&&std::same_as<decltype(0ll),signedlonglongint>&&std::same_as<decltype(0ul),unsignedlongint>&&std::same_as<decltype(0ull),unsignedlonglongint>&&std::same_as<decltype(0.l),longdouble>); template<typename T,typename...Ts>concept all_same=(...andstd::same_as<T, Ts>); static_assert( all_same<long,longint,signedlong,signedlongint>&& all_same<unsignedlong,unsignedlongint>&& all_same<longlong,longlongint,signedlonglong,signedlonglongint>&& all_same<unsignedlonglong,unsignedlonglongint>); #define OUT(...) std::cout << #__VA_ARGS__ << " = " << __VA_ARGS__ << '\n' int main(){std::cout.imbue(std::locale("en_US.UTF-8")); OUT(sizeof(long)); OUT(std::numeric_limits<long>::min()); OUT(std::numeric_limits<long>::max()); OUT(std::numeric_limits<unsignedlong>::max()); OUT(sizeof(longlong)); OUT(std::numeric_limits<longlong>::min()); OUT(std::numeric_limits<longlong>::max()); OUT(std::numeric_limits<unsignedlonglong>::max());} #undef OUT
Possible output:
sizeof(long) = 8std::numeric_limits<long>::min() = -9,223,372,036,854,775,808std::numeric_limits<long>::max() = 9,223,372,036,854,775,807std::numeric_limits<unsigned long>::max() = 18,446,744,073,709,551,615sizeof(long long) = 8std::numeric_limits<long long>::min() = -9,223,372,036,854,775,808std::numeric_limits<long long>::max() = 9,223,372,036,854,775,807std::numeric_limits<unsigned long long>::max() = 18,446,744,073,709,551,615
void,std::nullptr_t(since C++11).int.Modifiers:signed,unsigned,short,long.bool.Boolean literals:false,true.char,char8_t(since C++20),char16_t,char32_t(since C++11),wchar_t.float,double.