小编ALM*_*ack的帖子

如何在 Kotlin 中对 IntArray 进行 Base64 编码

如何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)

base64 kotlin

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

模板类默认类型和条件

我想对 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)

c++ templates default enable-if conditional-types

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

标签 统计

base64 ×1

c++ ×1

conditional-types ×1

default ×1

enable-if ×1

kotlin ×1

templates ×1