小编mik*_*keg的帖子

是否可以将std :: chrono :: duration与Rep类型一起使用为double?我尝试时在vs2012中遇到编译器错误

我得到以下编译器(vs2012)错误:

错误3错误C2679:二进制'+ =':找不到运算符,它采用类型为'const std :: chrono :: duration <_Rep,_Period>'的右手操作数(或者没有可接受的转换)c:\ program files(x86)\ microsoft visual studio 11.0\vc\include\chrono 749

我对持续时间的定义是:

// Tick interval type in nanoseconds
typedef std::chrono::duration<double, std::ratio<1, 100000000>> tick_interval_type;
Run Code Online (Sandbox Code Playgroud)

当我使用float时出现相同的错误...它仅在Rep类型的持续时间为整数时编译.

有人可以帮忙吗?

编辑(从输出更完整的日志):

c:\ program files(x86)\ microsoft visual studio 11.0\vc\include\chrono(749):error C2679:binary'+ =':找不到运算符,它采用类型为'const std :: chrono的右手操作数:: duration <_Rep,_Period>'(或没有可接受的转换)[_ Red = double,_Period = std :: nano] c:\ program files(x86)\ microsoft visual studio 11.0\vc\include\chrono( 166):可能是'std :: chrono :: duration <_Rep,_Period>&std :: chrono :: duration <_Rep,_Period> :: operator + =(const std :: chrono :: duration <_Rep,_Period>& …

c++ compiler-errors type-conversion c++11 c++-chrono

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

如何在安全(C++)中存储加密密钥?

我想在我的游戏中使用xxtea进行数据加密/解密.

以下是库使用的示例:

#include <stdio.h>
#include <string.h>
#include <xxtea.h>

int main() {
    const char *text = "Hello World! ??????";
    const char *key = "1234567890";
    size_t len;
    unsigned char *encrypt_data = xxtea_encrypt(text, strlen(text), key, &len);
    char *decrypt_data = xxtea_decrypt(encrypt_data, len, key, &len);
    if (strncmp(text, decrypt_data, len) == 0) {
        printf("success!\n");
    }
    else {
        printf("fail!\n");
    }
    free(encrypt_data);
    free(decrypt_data);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

如何保持钥匙本身的安全呢?

c++ encryption xxtea

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