Skip to content

Commit

Permalink
Revert fmtlib#456
Browse files Browse the repository at this point in the history
Revert fmtlib#456 because it causes issues for known types (fmtlib#495) and is not C++98-compatible.
  • Loading branch information
vitaut authored and Bjoern Thiel committed May 11, 2017
1 parent 0539746 commit 104bac8
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 84 deletions.
8 changes: 0 additions & 8 deletions fmt/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,14 +277,6 @@ typedef __int64 intmax_t;
(FMT_GCC_VERSION >= 303 && FMT_HAS_GXX_CXX11))
#endif

// Checks if decltype v1.1 is supported
// http://en.cppreference.com/w/cpp/compiler_support
#define FMT_HAS_DECLTYPE_INCOMPLETE_RETURN_TYPES \
(FMT_HAS_FEATURE(cxx_decltype_incomplete_return_types) || \
(FMT_GCC_VERSION >= 407 && FMT_HAS_GXX_CXX11) || \
FMT_MSC_VER >= 1900 || \
FMT_ICC_VERSION >= 1200)

#ifdef FMT_HEADER_ONLY
// If header only do not use extern templates.
# undef FMT_USE_EXTERN_TEMPLATES
Expand Down
34 changes: 0 additions & 34 deletions fmt/ostream.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,6 @@ struct ConvertToIntImpl<T, true> {

// Write the content of w to os.
FMT_API void write(std::ostream &os, Writer &w);

#if FMT_HAS_DECLTYPE_INCOMPLETE_RETURN_TYPES
template<typename T>
class is_streamable {
template<typename U>
static auto test(int) -> decltype(std::declval<std::ostream &>() << std::declval<U>(), std::true_type());

template<typename>
static auto test(...) -> std::false_type;

public:
static constexpr bool value = decltype(test<T>(0))::value;
};
#endif
} // namespace internal

// Formats a value.
Expand Down Expand Up @@ -110,26 +96,6 @@ void format_arg(BasicFormatter<Char, ArgFormatter_> &f,
*/
FMT_API void print(std::ostream &os, CStringRef format_str, ArgList args);
FMT_VARIADIC(void, print, std::ostream &, CStringRef)

#if __cplusplus >= 201103L
template<typename T, typename Char>
typename std::enable_if<
!std::is_same<
typename std::remove_cv<typename std::decay<T>::type>::type,
char *
>::value,
BasicWriter<Char>&
>::type
operator<<(BasicWriter<Char> &writer, const T &value) {
FMT_STATIC_ASSERT(internal::is_streamable<T>::value, "T must be Streamable");

internal::FormatBuf<Char> format_buf(writer.buffer());
std::basic_ostream<Char> output(&format_buf);
output << value;

return writer;
}
#endif
} // namespace fmt

#ifdef FMT_HEADER_ONLY
Expand Down
42 changes: 0 additions & 42 deletions test/ostream-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,6 @@ std::ostream &operator<<(std::ostream &os, EmptyTest) {
return os << "";
}

#if __cplusplus >= 201103L
struct UserDefinedTest { int i = 42; };

std::ostream &operator<<(std::ostream &os, const UserDefinedTest &u) {
return os << u.i;
}
#endif

TEST(OStreamTest, EmptyCustomOutput) {
EXPECT_EQ("", fmt::format("{}", EmptyTest()));
}
Expand All @@ -137,17 +129,6 @@ TEST(OStreamTest, WriteToOStream) {
EXPECT_EQ("foo", os.str());
}

#if __cplusplus >= 201103L
TEST(OStreamTest, WriteUserDefinedTypeToOStream) {
std::ostringstream os;
fmt::MemoryWriter w;
UserDefinedTest u;
w << "The answer is " << u;
fmt::internal::write(os, w);
EXPECT_EQ("The answer is 42", os.str());
}
#endif

TEST(OStreamTest, WriteToOStreamMaxSize) {
std::size_t max_size = std::numeric_limits<std::size_t>::max();
std::streamsize max_streamsize = std::numeric_limits<std::streamsize>::max();
Expand Down Expand Up @@ -191,26 +172,3 @@ TEST(OStreamTest, WriteToOStreamMaxSize) {
} while (size != 0);
fmt::internal::write(os, w);
}

#if __cplusplus >= 201103L
struct Xs {
const size_t size;
const std::string s;
Xs() : size(200), s(size, 'x') {}
};

inline std::ostream& operator<<(std::ostream& os, Xs const& xs) {
return os << xs.s;
}

TEST(OStreamTest, FormatBuf1) {
Xs xs;
fmt::MemoryWriter w;
int n = fmt::internal::INLINE_BUFFER_SIZE / xs.size + 1;
for (int i = 0; i < n; ++i)
w << xs;
EXPECT_EQ(w.size(), size_t(n * xs.size));
w << xs;
EXPECT_EQ(w.size(), size_t((n + 1) * xs.size));
}
#endif

0 comments on commit 104bac8

Please sign in to comment.