Skip to content

Instantly share code, notes, and snippets.

@pfultz2
pfultz2 / reveal1.cpp
Last active August 29, 2015 14:14
Transporting substitution failures
#include <iostream>
#include <vector>
#include <list>
template<class T>
struct always_void
{
typedef void type;
};
@pfultz2
pfultz2 / state_monad.cpp
Created November 11, 2014 01:29
State monad implemented in C++14
#include <utility>
#include <iostream>
struct void_
{
template<typename Stream>
friend Stream &operator<<(Stream &s, void_)
{
return s << "()";
}
template<class T>
struct lazy_value
{
T x;
lazy_value(T x) : x(x)
{}
std::string to_string() const
{
return boost::lexical_cast<std::string(x);
}
@pfultz2
pfultz2 / fusion-orm.cpp
Created July 16, 2014 15:53
A simple example of how to use Boost.Fusion for ORM
#include <iostream>
#include <sstream>
#include <type_traits>
#include <boost/mpl/range_c.hpp>
#include <boost/fusion/adapted/struct/define_assoc_struct.hpp>
#include <boost/fusion/algorithm/iteration/for_each.hpp>
#include <boost/fusion/algorithm/transformation/zip.hpp>
#include <boost/fusion/sequence/intrinsic/at_c.hpp>
#include <boost/fusion/sequence/intrinsic/at.hpp>
@pfultz2
pfultz2 / pr13309.34.patch
Last active January 2, 2016 23:29
13309 Patch for clang 3.4. This will improve the backtrace for sfinae errors.
diff --git a/tools/clang/include/clang/Sema/TemplateDeduction.h b/tools/clang/include/clang/Sema/TemplateDeduction.h
index 1daa689..793a50a 100644
--- a/tools/clang/include/clang/Sema/TemplateDeduction.h
+++ b/tools/clang/include/clang/Sema/TemplateDeduction.h
@@ -36,6 +36,9 @@ class TemplateDeductionInfo {
/// deduction is occurring.
SourceLocation Loc;
+ /// \brief Should we suppress errors during substitution?
+ bool IsSFINAEContext;
@pfultz2
pfultz2 / pr13309.patch
Last active January 2, 2016 22:59
Patch for clang to improve sfinae errors.
Index: include/clang/Sema/TemplateDeduction.h
===================================================================
--- a/tools/clang/include/clang/Sema/TemplateDeduction.h (revision 159968)
+++ b/tools/clang/include/clang/Sema/TemplateDeduction.h (working copy)
@@ -39,6 +39,9 @@
/// deduction is occurring.
SourceLocation Loc;
+ /// \brief Should we suppress errors during substitution?
+ bool IsSFINAEContext;