Skip to content

Instantly share code, notes, and snippets.

View shaomeng's full-sized avatar

Samuel Li shaomeng

  • Nvidia
  • Santa Clara, CA
View GitHub Profile
@shaomeng
shaomeng / mul_vs_bitset.cpp
Last active July 20, 2022 23:42
What's the fastest method to pack an array of booleans to integers?
#include <vector>
#include <bitset>
#include <array>
#include <random>
#include <algorithm>
#include <cstring>
#include <chrono>
#include <iostream>
void pack_booleans(std::vector<uint8_t>& dest, const std::vector<bool>& src)
@shaomeng
shaomeng / reference.cpp
Created March 21, 2020 21:33
pass by reference
#include <iostream>
#include <memory>
using buffer_type = std::unique_ptr<float[]>;
template< typename T >
void print_2nd_val( T ptr )
{
std::cout << ptr[1] << std::endl;
}