Commit 1f1ba906 authored by Elizabeth Smith's avatar Elizabeth Smith Committed by Tudor Bosman

Expression SFINAE issue in base.h

Summary:
MSVC 14 is still broken with expression sfinae - and the things that break are often strange
Moving this out into two expr templates solves the compilation issue

Test Plan: fbconfig -r folly && fbmake runtests

Reviewed By: tjackson@fb.com

FB internal diff: D1413297
parent d7f1adb6
......@@ -537,12 +537,29 @@ enum MemberType {
Mutable
};
/**
* These exist because MSVC has problems with expression SFINAE in templates
* assignment and comparisons don't work properly without being pulled out
* of the template declaration
*/
template <MemberType Constness> struct ExprIsConst {
enum {
value = Constness == Const
};
};
template <MemberType Constness> struct ExprIsMutable {
enum {
value = Constness == Mutable
};
};
template<MemberType Constness = Const,
class Class,
class Return,
class Mem = ConstMemberFunction<Class, Return>,
class Map = detail::Map<Mem>>
typename std::enable_if<Constness == Const, Map>::type
typename std::enable_if<ExprIsConst<Constness>::value, Map>::type
member(Return (Class::*member)() const) {
return Map(Mem(member));
}
......@@ -552,7 +569,7 @@ template<MemberType Constness = Mutable,
class Return,
class Mem = MemberFunction<Class, Return>,
class Map = detail::Map<Mem>>
typename std::enable_if<Constness == Mutable, Map>::type
typename std::enable_if<ExprIsMutable<Constness>::value, Map>::type
member(Return (Class::*member)()) {
return Map(Mem(member));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment