Skip to content

Instantly share code, notes, and snippets.

@kernhanda
kernhanda / vector_to_tuple.hpp
Last active October 13, 2018 23:45
Simple snippet to convert a vector to a tuple.
namespace detail {
template <typename... Args, typename T, size_t... I>
std::tuple<Args...> vector_to_tuple(const std::vector<T>& t, std::index_sequence<I...>) {
return std::tuple<Args...>{ t[I]... };
}
}
template <typename... Args, typename T>
auto vector_to_tuple(const std::vector<T>& t) {
return detail::vector_to_tuple<Args...>(t, std::make_index_sequence<sizeof...(Args)>());
@kernhanda
kernhanda / halide_test.cpp
Last active March 21, 2018 06:39
Assert: registry.instances.find(key) == registry.instances.end()
#include "Halide.h"
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <iostream>
#include <memory>
#include <random>
using namespace Halide;
@kernhanda
kernhanda / unused_args.hpp
Last active October 1, 2017 01:18
Use to suppress unused parameters and variables in a cross-platform manner without macros
// Use to suppress unused parameters and variables in a cross-platform manner without macros
#pragma once
#include <utility>
template <typename T1>
constexpr void unused_args(T1&& t1)
{
(void)t1;