Skip to content

Instantly share code, notes, and snippets.

View EricWF's full-sized avatar

Eric EricWF

View GitHub Profile
#include <typeinfo>
class bad_enum_cast : public std::bad_cast
{
public:
const char* what() const noexcept
{ return "bad enum cast"; }
};
template <typename Enum, typename Integral>
@EricWF
EricWF / magic.cpp
Last active December 29, 2015 14:39
Ok, so as far as I'm concerned this is currently magic. This is a copy of mpl::if_ created by https://github.com/ldionne I wanted to share because, well its beautiful...
#include <iostream>
#include <string>
using std::cout;
using std::endl;
#define UNUSED(x) ((void)x)
#define INIT() UNUSED(argc); UNUSED(argv); UNUSED(envp); cout << std::boolalpha;
namespace elib{} using namespace elib;
void mymain(int, char**, char**);
int main(int argc, char *argv[], char *envp[]) { mymain(argc, argv, envp); return 0;}
#ifndef ENTITY_HPP
#define ENTITY_HPP
# include <elib/aux.hpp>
# include <elib/any.hpp>
# include <unordered_map>
# include <typeinfo>
# include <typeindex>
namespace example
/// this is the method "declaration". Just like you declare methods in a header file for a class, this is how you declare
/// methods for an entity. It is important to remember that these are "methods". That means that while the user may see
/// the function signature "void(level &)" the actual signature is "void(entity &, level &)". It has to take a "this" reference.
/// When writing methods you must write the method using the internal interface with the "this" reference.
/// This is the declaration.
/// It should be considered similar to declaring a function as so:
/// class entity {
/// void update_(level &);
enum class my_big_enum
{
/* imagine this changes a lot */
};
@EricWF
EricWF / Order
Last active August 29, 2015 13:57
1. implicit conversion
2. explicit conversion
3. stream operator
4. to_string
enum class A
{
none, one
};
struct A_parser
{
static A parse(std::string const & option)
{
// Copyright Aleksey Gurtovoy 2000-2004
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Id: logical_op.hpp 49267 2008-10-11 06:19:02Z agurtovoy $
LIBCXX=$HOME/workspace/libcxx
BUILDLIBCXX=$HOME/workspace/build-libcxx
LIBCXXABI_INCLUDE_PATH="/home/eric/workspace/libcxxabi/include"
rm -rf $BUILDLIBCXX
rm -f $LIBCXX/test/lit.site.cfg
mkdir $BUILDLIBCXX
cd $BUILDLIBCXX
cmake -DLIBCXX_CXX_ABI=libcxxabi -DLIBCXX_LIBCXXABI_INCLUDE_PATHS=$LIBCXXABI_INCLUDE_PATH\
"$@"\
$LIBCXX
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..60dc367
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+# python temp files
+*.pyc
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt