Commit 570ec333 authored by Philip Pronin's avatar Philip Pronin Committed by Jordan DeLong

do not include iostream from Range.h

Summary:
folly/Range.h is extensively used in fbcode, try to avoid including
<iostream> (which is pretty heavy), include forward declarations
(<iosfwd>) instead.

Also transitioned it from 'std type_traits' + 'boost type_traits' to
'std type_traits'.

Test Plan: compiled, ran tests

Reviewed By: soren@fb.com

FB internal diff: D774834
parent bac6c8f1
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "folly/Range.h" #include "folly/Range.h"
#include <emmintrin.h> // __v16qi #include <emmintrin.h> // __v16qi
#include <iostream>
#include "folly/Likely.h" #include "folly/Likely.h"
namespace folly { namespace folly {
......
...@@ -25,13 +25,11 @@ ...@@ -25,13 +25,11 @@
#include <glog/logging.h> #include <glog/logging.h>
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
#include <iostream> #include <iosfwd>
#include <string> #include <string>
#include <stdexcept> #include <stdexcept>
#include <type_traits> #include <type_traits>
#include <boost/operators.hpp> #include <boost/operators.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/type_traits.hpp>
#include <bits/c++config.h> #include <bits/c++config.h>
#include "folly/CpuId.h" #include "folly/CpuId.h"
#include "folly/Traits.h" #include "folly/Traits.h"
...@@ -77,9 +75,9 @@ namespace detail { ...@@ -77,9 +75,9 @@ namespace detail {
* For random-access iterators, the value before is simply i[-1]. * For random-access iterators, the value before is simply i[-1].
*/ */
template <class Iter> template <class Iter>
typename boost::enable_if_c< typename std::enable_if<
boost::is_same<typename std::iterator_traits<Iter>::iterator_category, std::is_same<typename std::iterator_traits<Iter>::iterator_category,
std::random_access_iterator_tag>::value, std::random_access_iterator_tag>::value,
typename std::iterator_traits<Iter>::reference>::type typename std::iterator_traits<Iter>::reference>::type
value_before(Iter i) { value_before(Iter i) {
return i[-1]; return i[-1];
...@@ -89,9 +87,9 @@ value_before(Iter i) { ...@@ -89,9 +87,9 @@ value_before(Iter i) {
* For all other iterators, we need to use the decrement operator. * For all other iterators, we need to use the decrement operator.
*/ */
template <class Iter> template <class Iter>
typename boost::enable_if_c< typename std::enable_if<
!boost::is_same<typename std::iterator_traits<Iter>::iterator_category, !std::is_same<typename std::iterator_traits<Iter>::iterator_category,
std::random_access_iterator_tag>::value, std::random_access_iterator_tag>::value,
typename std::iterator_traits<Iter>::reference>::type typename std::iterator_traits<Iter>::reference>::type
value_before(Iter i) { value_before(Iter i) {
return *--i; return *--i;
...@@ -116,7 +114,7 @@ public: ...@@ -116,7 +114,7 @@ public:
typedef std::size_t size_type; typedef std::size_t size_type;
typedef Iter iterator; typedef Iter iterator;
typedef Iter const_iterator; typedef Iter const_iterator;
typedef typename boost::remove_reference< typedef typename std::remove_reference<
typename std::iterator_traits<Iter>::reference>::type typename std::iterator_traits<Iter>::reference>::type
value_type; value_type;
typedef typename std::iterator_traits<Iter>::reference reference; typedef typename std::iterator_traits<Iter>::reference reference;
...@@ -452,11 +450,11 @@ template <class A, class B> ...@@ -452,11 +450,11 @@ template <class A, class B>
struct ComparableAsStringPiece { struct ComparableAsStringPiece {
enum { enum {
value = value =
(boost::is_convertible<A, StringPiece>::value (std::is_convertible<A, StringPiece>::value
&& boost::is_same<B, StringPiece>::value) && std::is_same<B, StringPiece>::value)
|| ||
(boost::is_convertible<B, StringPiece>::value (std::is_convertible<B, StringPiece>::value
&& boost::is_same<A, StringPiece>::value) && std::is_same<A, StringPiece>::value)
}; };
}; };
...@@ -467,7 +465,7 @@ struct ComparableAsStringPiece { ...@@ -467,7 +465,7 @@ struct ComparableAsStringPiece {
*/ */
template <class T, class U> template <class T, class U>
typename typename
boost::enable_if_c<detail::ComparableAsStringPiece<T, U>::value, bool>::type std::enable_if<detail::ComparableAsStringPiece<T, U>::value, bool>::type
operator==(const T& lhs, const U& rhs) { operator==(const T& lhs, const U& rhs) {
return StringPiece(lhs) == StringPiece(rhs); return StringPiece(lhs) == StringPiece(rhs);
} }
...@@ -477,7 +475,7 @@ operator==(const T& lhs, const U& rhs) { ...@@ -477,7 +475,7 @@ operator==(const T& lhs, const U& rhs) {
*/ */
template <class T, class U> template <class T, class U>
typename typename
boost::enable_if_c<detail::ComparableAsStringPiece<T, U>::value, bool>::type std::enable_if<detail::ComparableAsStringPiece<T, U>::value, bool>::type
operator<(const T& lhs, const U& rhs) { operator<(const T& lhs, const U& rhs) {
return StringPiece(lhs) < StringPiece(rhs); return StringPiece(lhs) < StringPiece(rhs);
} }
...@@ -487,7 +485,7 @@ operator<(const T& lhs, const U& rhs) { ...@@ -487,7 +485,7 @@ operator<(const T& lhs, const U& rhs) {
*/ */
template <class T, class U> template <class T, class U>
typename typename
boost::enable_if_c<detail::ComparableAsStringPiece<T, U>::value, bool>::type std::enable_if<detail::ComparableAsStringPiece<T, U>::value, bool>::type
operator>(const T& lhs, const U& rhs) { operator>(const T& lhs, const U& rhs) {
return StringPiece(lhs) > StringPiece(rhs); return StringPiece(lhs) > StringPiece(rhs);
} }
...@@ -497,7 +495,7 @@ operator>(const T& lhs, const U& rhs) { ...@@ -497,7 +495,7 @@ operator>(const T& lhs, const U& rhs) {
*/ */
template <class T, class U> template <class T, class U>
typename typename
boost::enable_if_c<detail::ComparableAsStringPiece<T, U>::value, bool>::type std::enable_if<detail::ComparableAsStringPiece<T, U>::value, bool>::type
operator<=(const T& lhs, const U& rhs) { operator<=(const T& lhs, const U& rhs) {
return StringPiece(lhs) <= StringPiece(rhs); return StringPiece(lhs) <= StringPiece(rhs);
} }
...@@ -507,7 +505,7 @@ operator<=(const T& lhs, const U& rhs) { ...@@ -507,7 +505,7 @@ operator<=(const T& lhs, const U& rhs) {
*/ */
template <class T, class U> template <class T, class U>
typename typename
boost::enable_if_c<detail::ComparableAsStringPiece<T, U>::value, bool>::type std::enable_if<detail::ComparableAsStringPiece<T, U>::value, bool>::type
operator>=(const T& lhs, const U& rhs) { operator>=(const T& lhs, const U& rhs) {
return StringPiece(lhs) >= StringPiece(rhs); return StringPiece(lhs) >= StringPiece(rhs);
} }
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <dlfcn.h> #include <dlfcn.h>
#include <exception> #include <exception>
#include <iostream>
#include <glog/logging.h> #include <glog/logging.h>
#include "folly/experimental/exception_tracer/ExceptionAbi.h" #include "folly/experimental/exception_tracer/ExceptionAbi.h"
......
...@@ -20,7 +20,8 @@ ...@@ -20,7 +20,8 @@
#ifndef FOLLY_EXPERIMENTAL_EXCEPTION_TRACER_EXCEPTIONTRACER_H_ #ifndef FOLLY_EXPERIMENTAL_EXCEPTION_TRACER_EXCEPTIONTRACER_H_
#define FOLLY_EXPERIMENTAL_EXCEPTION_TRACER_EXCEPTIONTRACER_H_ #define FOLLY_EXPERIMENTAL_EXCEPTION_TRACER_EXCEPTIONTRACER_H_
#include <iostream> #include <cstdint>
#include <iosfwd>
#include <typeinfo> #include <typeinfo>
#include <vector> #include <vector>
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
*/ */
#include <iostream>
#include <stdexcept> #include <stdexcept>
#include "folly/experimental/exception_tracer/ExceptionTracer.h" #include "folly/experimental/exception_tracer/ExceptionTracer.h"
......
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