Skip to content

Instantly share code, notes, and snippets.

View njlr's full-sized avatar
🌏
F# ing

njlr njlr

🌏
F# ing
View GitHub Profile
genrule(
 name = 'single-header',
 out = 'mathutils.hpp',
 cmd = 'echo "' + single_header + '" > $OUT',
)
single_header = '\n'.join([
  '#ifndef MATHUTILS_HPP',
  '#define MATHUTILS_HPP',
  '',
  ] + [
  '#include <mathutils/' + i + '> ' for i, _ in mathutils_headers.items()
  ] + [
  '',
  '#endif',
  '',
{
 'add.hpp': 'mathutils/include/add.hpp', 
 'sub.hpp': 'mathutils/include/sub.hpp'
}
print subdir_glob([
 (‘mathutils/include’, ‘**/*.hpp’),
])
mathutils
├── include
│ ├── add.hpp
│ └── sub.hpp
└── src
 ├── add.cpp
 └── sub.cpp
#include <mathutils/mathutils.hpp>
#ifndef MATHUTILS_SINGLE_INCLUDE_HPP
#define MATHUTILS_SINGLE_INCLUDE_HPP
#include <mathutils/add.hpp>
#include <mathutils/sub.hpp>
// etc…
#endif
#include <mathutils/add.hpp>
#include <mathutils/sub.hpp>
// etc…
mathutils
└── include
 ├── add.hpp
 ├── sub.hpp
 └── …
// ...
virtual void copy(void* memory) const {
  new (memory) Model<F, ReturnType, Xs...>(f);
  }
template<unsigned rhsSize, std::enable_if_t<(rhsSize <= size), bool> = 0>
  SmallFun(SmallFun<ReturnType(Xs...), rhsSize> const& rhs) {
  rhs.copy(memory);
  }