now works with -fno-exceptions and -fno-rtti

llvm-svn: 110828
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: 54b409fdb9489b305bf95f4d4f52b49c7926c429
diff --git a/include/functional b/include/functional
index e645a55..430f325 100644
--- a/include/functional
+++ b/include/functional
@@ -1000,8 +1000,10 @@
     virtual void destroy() = 0;
     virtual void destroy_deallocate() = 0;
     virtual _R operator()(_ArgTypes&& ...) = 0;
+#ifndef _LIBCPP_NO_RTTI
     virtual const void* target(const type_info&) const = 0;
     virtual const std::type_info& target_type() const = 0;
+#endif
 };
 
 template<class _FD, class _Alloc, class _FB> class __func;
@@ -1019,8 +1021,10 @@
     virtual void destroy();
     virtual void destroy_deallocate();
     virtual _R operator()(_ArgTypes&& ... __arg);
+#ifndef _LIBCPP_NO_RTTI
     virtual const void* target(const type_info&) const;
     virtual const std::type_info& target_type() const;
+#endif
 };
 
 template<class _F, class _Alloc, class _R, class ..._ArgTypes>
@@ -1066,6 +1070,8 @@
     return __invoke(__f_.first(), _STD::forward<_ArgTypes>(__arg)...);
 }
 
+#ifndef _LIBCPP_NO_RTTI
+
 template<class _F, class _Alloc, class _R, class ..._ArgTypes>
 const void*
 __func<_F, _Alloc, _R(_ArgTypes...)>::target(const type_info& __ti) const
@@ -1082,6 +1088,8 @@
     return typeid(_F);
 }
 
+#endif
+
 }  // __function
 
 template<class _R, class ..._ArgTypes>
@@ -1163,10 +1171,12 @@
     // 20.7.16.2.4, function invocation:
     _R operator()(_ArgTypes...) const;
 
+#ifndef _LIBCPP_NO_RTTI
     // 20.7.16.2.5, function target access:
     const std::type_info& target_type() const;
     template <typename _T> _T* target();
     template <typename _T> const _T* target() const;
+#endif
 };
 
 template<class _R, class ..._ArgTypes>
@@ -1331,11 +1341,15 @@
 _R
 function<_R(_ArgTypes...)>::operator()(_ArgTypes... __arg) const
 {
+#ifndef _LIBCPP_NO_EXCEPTIONS
     if (__f_ == 0)
         throw bad_function_call();
+#endif
     return (*__f_)(_STD::forward<_ArgTypes>(__arg)...);
 }
 
+#ifndef _LIBCPP_NO_RTTI
+
 template<class _R, class ..._ArgTypes>
 const std::type_info&
 function<_R(_ArgTypes...)>::target_type() const
@@ -1365,6 +1379,8 @@
     return (const _T*)__f_->target(typeid(_T));
 }
 
+#endif
+
 template <class _R, class... _ArgTypes> 
 inline _LIBCPP_INLINE_VISIBILITY
 bool