內const int的我有一個配置類 // config.hpp
class Config {
public:
static constexpr int a = 1;
static constexpr int b = 1;
}
和main.cpp中包括 // main.cpp
#include "config.hpp"
int main() {
這將編譯: int main() {
const int x = 123;
auto g = []() { std::cout << x << "\n"; };
g();
}
但這: int main(){
const float x = 123;
auto g = []() { std::cout << x << "\n"; };
我碰到過這樣的伎倆來定義一個全局數組: // This template utilizes the One Definition Rule to create global arrays in a header.
template<typename unused=void>
struct globals_struct
{
static const uint8 s_str_seria