Skip to content

Instantly share code, notes, and snippets.

@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;
@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 / 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>
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 / 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 << "()";
}
@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 / reveal2.cpp
Created February 1, 2015 05:37
Transporting substitution failures for "advance" function
#include <iostream>
#include <vector>
#include <list>
#define REQUIRES(...) typename std::enable_if<(__VA_ARGS__), int>::type = 0
#define REQUIRE_OF(...) template<class Id> using apply = typename std::enable_if<(Id()(__VA_ARGS__)), int>::type
template<class T>
struct always_void
#include <iostream>
#include <vector>
#include <list>
#include <tick/builder.h>
#include <tick/requires.h>
#include <fit/lambda.h>
#include <fit/function.h>
#include <fit/conditional.h>
#include <fit/reveal.h>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <tuple>
#include <fit/always.h>
#include <fit/capture.h>
#include <fit/identity.h>
#include <fit/fix.h>
--- Makefile.in.orig 2012-10-28 05:30:09.000000000 -0500
+++ Makefile.in 2013-12-10 12:36:34.000000000 -0600
@@ -1,6 +1,8 @@
+PREFIX := @prefix@
CXX := @CXX@
-CXXFLAGS := -DHAVE_LIBSAMPLERATE -DHAVE_FFTW3 -DFFTW_DOUBLE_ONLY -DNO_THREAD_CHECKS -DUSE_PTHREADS -DNO_TIMING -DNDEBUG @CXXFLAGS@ @SRC_CFLAGS@ @SNDFILE_CFLAGS@ @FFTW_CFLAGS@ @Vamp_CFLAGS@ -Irubberband -I. -Isrc $(OPTFLAGS)
+CC := @CC@
+CXXFLAGS := -DHAVE_LIBSAMPLERATE -DHAVE_FFTW3 -DFFTW_DOUBLE_ONLY -DNO_THREAD_CHECKS -DUSE_PTHREADS -DNO_TIMING -DNDEBUG -Irubberband -I. -Isrc @CXXFLAGS@ @SRC_CFLAGS@ @SNDFILE_CFLAGS@ @FFTW_CFLAGS@ @Vamp_CFLAGS@ $(OPTFLAGS)
CFLAGS := @CFLAGS@ $(OPTFLAGS)