当我编写C++代码时,我尝试使用using <X>
防止污染太多。在Crypto ++中,它在一种情况下给我带来问题。这种情况是CryptoPP命名空间中的ASN1命名空间(它只显示在一个地方)。使用嵌套命名空间声明“using namespace”时出错(“namespace xxx :: yyy不允许在使用声明中”)
以下是Crypto ++中的声明:http://www.cryptopp.com/docs/ref/oids_8h_source.html。
我可以使用,例如,secp256r1
曲线有:
CryptoPP::ASN1::secp256r1();
不过,我还没有想出一个办法使用声明它。当我尝试:
#include <cryptopp/asn.h>
#include <cryptopp/oids.h>
using CryptoPP::ASN1;
这最终导致error: namespace ‘CryptoPP::ASN1’ not allowed in using-declaration
,然后error: ‘ASN1’ has not been declared
在下面的(我想他们俩):
ECIES<ECP>::Decryptor d1(prng, secp256r1());
ECIES<ECP>::Decryptor d2(prng, ASN1::secp256r1());
一个人如何使用using
语句时,有不止一个命名空间?
$ g++ -version
i686-apple-darwin11-llvm-g++-4.2
'使用命名空间CryptoPP :: ASN1;' –