Fixed issue with formatting to an array of chars
It should fix #1169. Added a couple of tests to prevent such issues in the future. Please, let me know if I forgot about any `prepared_format::format_to` use case.
{"label": "fmtlib:master", "ref": "master", "sha": "87fbc6f7566e4d3266bd3a2cd69f6c90e1aefa5d"}
It's reproducible by such a simple code:
```cpp
#include <fmt/prepare.h>

int main()
{
    char buffer[32];
    auto prepared = fmt::prepare<int>("12{}");
    auto formatted = prepared.format_to(buffer, 3);
}
```

See an [example](https://gcc.godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(j:1,lang:c%2B%2B,source:'%23include+%3Cfmt/prepare.h%3E%0A%0Aint+main()%0A%7B%0A++++char+buffer%5B32%5D%3B%0A++++auto+prepared+%3D+fmt::prepare%3Cint%3E(%2212%7B%7D%22)%3B%0A++++auto+formatted+%3D+prepared.format_to(buffer,+3)%3B%0A%7D%0A'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),k:34.12334812716754,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:clang800,filters:(b:'0',binary:'1',commentOnly:'0',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'1',trim:'1'),lang:c%2B%2B,libs:!((name:boost,ver:'168'),(name:fmt,ver:trunk)),options:'-std%3Dgnu%2B%2B17+-O2',source:1),l:'5',n:'0',o:'x86-64+clang+8.0.0+(Editor+%231,+Compiler+%231)+C%2B%2B',t:'0')),k:28.69276284992644,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compiler:1,editor:1,wrap:'1'),l:'5',n:'0',o:'%231+with+x86-64+clang+8.0.0',t:'0')),k:37.183889022906065,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4)
fmt::prepare fails to compile formatting to an array of chars
diff --git a/include/fmt/prepare.h b/include/fmt/prepare.h
index 0ac9218875a2..791858afdc92 100644
--- a/include/fmt/prepare.h
+++ b/include/fmt/prepare.h
@@ -217,7 +217,8 @@ class prepared_format {
   std::basic_string<char_type> format(const Args&... args) const {
     basic_memory_buffer<char_type> buffer;
     typedef back_insert_range<internal::buffer<char_type>> range;
-    this->vformat_to(range(buffer), make_args_checked(format_, args...));
+    this->vformat_to(range(buffer), basic_format_args<context>{
+                                        make_args_checked(format_, args...)});
     return to_string(buffer);
   }
 
@@ -226,7 +227,8 @@ class prepared_format {
       std::back_insert_iterator<Container> out, const Args&... args) const {
     internal::container_buffer<Container> buffer(internal::get_container(out));
     typedef back_insert_range<internal::buffer<char_type>> range;
-    this->vformat_to(range(buffer), make_args_checked(format_, args...));
+    this->vformat_to(range(buffer), basic_format_args<context>{
+                                        make_args_checked(format_, args...)});
     return out;
   }
 
@@ -242,18 +244,20 @@ class prepared_format {
   inline typename buffer_context<char_type>::iterator format_to(
       basic_memory_buffer<char_type, SIZE>& buf, const Args&... args) const {
     typedef back_insert_range<internal::buffer<char_type>> range;
-    return this->vformat_to(range(buf), make_args_checked(format_, args...));
+    return this->vformat_to(
+        range(buf),
+        basic_format_args<context>{make_args_checked(format_, args...)});
   }
 
  private:
   typedef buffer_context<char_type> context;
 
-  template <typename Range>
-  typename context::iterator vformat_to(Range out,
-                                        basic_format_args<context> args) const {
+  template <typename Range, typename Context>
+  auto vformat_to(Range out, basic_format_args<Context> args) const ->
+      typename Context::iterator {
     const auto format_view = internal::to_string_view(format_);
     basic_parse_context<char_type> parse_ctx(format_view);
-    context ctx(out.begin(), args);
+    Context ctx(out.begin(), args);
 
     const auto& parts = parts_provider_.parts();
     for (auto part_it = parts.begin(); part_it != parts.end(); ++part_it) {

diff --git a/test/prepare-test.cc b/test/prepare-test.cc
index 64fe98c11091..a210178b50b4 100644
--- a/test/prepare-test.cc
+++ b/test/prepare-test.cc
@@ -475,7 +475,7 @@ TEST(PrepareTest, CopyPreparedFormat_InternalStringViewsAreNotInvalidated) {
   }
 }
 
-TEST(PepareTest, ReusedPreparedFormatType) {
+TEST(PrepareTest, ReusedPreparedFormatType) {
   typedef fmt::prepared_format<std::string, int>::type prepared_format;
 
   prepared_format prepared = fmt::prepare<prepared_format>("The {} is {}.");
@@ -637,3 +637,58 @@ TEST(PrepareTest, PassUserTypeFormat) {
   const auto prepared = fmt::prepare<int>(user_format("test {}"));
   EXPECT_EQ("test 42", prepared.format(42));
 }
+
+TEST(PrepareTest, FormatToArrayOfChars) {
+  char buffer[32] = {0};
+  const auto prepared = fmt::prepare<int>("4{}");
+  prepared.format_to(buffer, 2);
+  EXPECT_EQ(std::string("42"), buffer);
+  wchar_t wbuffer[32] = {0};
+  const auto wprepared = fmt::prepare<int>(L"4{}");
+  wprepared.format_to(wbuffer, 2);
+  EXPECT_EQ(std::wstring(L"42"), wbuffer);
+}
+
+TEST(PrepareTest, FormatToIterator) {
+  std::string s(2, ' ');
+  const auto prepared = fmt::prepare<int>("4{}");
+  prepared.format_to(s.begin(), 2);
+  EXPECT_EQ("42", s);
+  std::wstring ws(2, L' ');
+  const auto wprepared = fmt::prepare<int>(L"4{}");
+  wprepared.format_to(ws.begin(), 2);
+  EXPECT_EQ(L"42", ws);
+}
+
+TEST(PrepareTest, FormatToBackInserter) {
+  std::string s;
+  const auto prepared = fmt::prepare<int>("4{}");
+  prepared.format_to(std::back_inserter(s), 2);
+  EXPECT_EQ("42", s);
+  std::wstring ws;
+  const auto wprepared = fmt::prepare<int>(L"4{}");
+  wprepared.format_to(std::back_inserter(ws), 2);
+  EXPECT_EQ(L"42", ws);
+}
+
+TEST(PrepareTest, FormatToBasicMemoryBuffer) {
+  fmt::basic_memory_buffer<char, 100> buffer;
+  const auto prepared = fmt::prepare<int>("4{}");
+  prepared.format_to(buffer, 2);
+  EXPECT_EQ("42", to_string(buffer));
+  fmt::basic_memory_buffer<wchar_t, 100> wbuffer;
+  const auto wprepared = fmt::prepare<int>(L"4{}");
+  wprepared.format_to(wbuffer, 2);
+  EXPECT_EQ(L"42", to_string(wbuffer));
+}
+
+TEST(PrepareTest, FormatToMemoryBuffer) {
+  fmt::memory_buffer buffer;
+  const auto prepared = fmt::prepare<int>("4{}");
+  prepared.format_to(buffer, 2);
+  EXPECT_EQ("42", to_string(buffer));
+  fmt::wmemory_buffer wbuffer;
+  const auto wprepared = fmt::prepare<int>(L"4{}");
+  wprepared.format_to(wbuffer, 2);
+  EXPECT_EQ(L"42", to_string(wbuffer));
+}

{"prepare-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "locale-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "ostream-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "ranges-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "core-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "scan-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "color-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "grisu-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "chrono-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "format-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "gtest-extra-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "posix-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "assert-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "posix-mock-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "printf-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "format-impl-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "custom-formatter-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}}
{"prepare-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "locale-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "ostream-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "ranges-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "core-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "scan-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "color-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "grisu-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "chrono-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "format-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "gtest-extra-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "posix-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "assert-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "posix-mock-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "printf-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "format-impl-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}, "custom-formatter-test": {"run": "PASS", "test": "NONE", "fix": "PASS"}}
{"passed_count": 17, "failed_count": 0, "skipped_count": 0, "passed_tests": ["format-test", "gtest-extra-test", "prepare-test", "locale-test", "posix-test", "ostream-test", "ranges-test", "assert-test", "posix-mock-test", "core-test", "printf-test", "color-test", "scan-test", "format-impl-test", "grisu-test", "custom-formatter-test", "chrono-test"], "failed_tests": [], "skipped_tests": []}
{"passed_count": 0, "failed_count": 0, "skipped_count": 0, "passed_tests": [], "failed_tests": [], "skipped_tests": []}
{"passed_count": 17, "failed_count": 0, "skipped_count": 0, "passed_tests": ["format-test", "gtest-extra-test", "prepare-test", "locale-test", "posix-test", "ostream-test", "ranges-test", "assert-test", "posix-mock-test", "core-test", "printf-test", "color-test", "scan-test", "format-impl-test", "grisu-test", "custom-formatter-test", "chrono-test"], "failed_tests": [], "skipped_tests": []}