小编Ari*_*iel的帖子

c中的内联函数

内联函数可以在.h中声明并在.c中定义一次吗?

c inline function

9
推荐指数
1
解决办法
8057
查看次数

c ++中的命名空间别名

我使用c ++ 11,而我需要一些来自c ++ 17库的类.当使用添加类的boost时,我希望执行以下操作:

#if __cplusplus < CPP17
using std::any = boost::any;  
#endif
Run Code Online (Sandbox Code Playgroud)

不允许使用此类别名.同时扩展std命名空间会导致 未定义的行为.我希望我的代码看起来与c ++版本相同.有明确的方法吗?

c++ namespaces c++11

8
推荐指数
2
解决办法
2006
查看次数

C++:包含它所属的类的联合

虽然这个代码编译没有任何错误,但我怀疑它将按预期工作.允许这样的嵌套吗?我不能使用boost和c ++ 17.

class Node;

typedef struct Value {      
    ValueTag type;

    union {         
        std::int32_t                          integerValue;
        std::float_t                          floatValue;
        bool                                  boolValue;
        std::vector<Node>                     arrayValue;
        std::unordered_map<std::string, Node> dictionaryValue;
    };          
} Value;

class Node {                
private:        
    Value m_value;          
public:                 
    virtual ~Node();    
};
Run Code Online (Sandbox Code Playgroud)

c++ clang unions c++11

1
推荐指数
1
解决办法
198
查看次数

标签 统计

c++ ×2

c++11 ×2

c ×1

clang ×1

function ×1

inline ×1

namespaces ×1

unions ×1