如何intArrayOf使用 Kotlin 对 buff 进行 Base64 编码。
val vec = intArrayOf(1,2,3,4,5)
val data =?!
val base64Encoded = Base64.encodeToString(data, Base64.DEFAULT);
Run Code Online (Sandbox Code Playgroud) 我想对 MyClass 使用 std::enable_if 以便仅接受 (uint32_t | uint64_t) 并且同时如果用户没有提供任何类型;根据以下条件选择默认值。
但我无法让它发挥作用。(C++17)
#include <vector>
#include <cstdint>
template <typename T=std::conditional_t<sizeof(void*) == 8, std::uint64_t, std::uint32_t>>
class MyClass
{
private:
std::vector<T> vs;
public:
// ...
};
int main(){
MyClass a; // OK, the defaut type is used either uint32_t or uint64_t
MyClass<std::uint32_t> b; // Ok, use the user provided type
MyClass<long> c; // must not compile, T is not one of uint32_t, uint64_t
}
Run Code Online (Sandbox Code Playgroud)