is_saving.hpp
Go to the documentation of this file.
1 
17 #ifndef MLPACK_CORE_CEREAL_IS_SAVING_HPP
18 #define MLPACK_CORE_CEREAL_IS_SAVING_HPP
19 
20 #include <cereal/archives/binary.hpp>
21 #include <cereal/archives/portable_binary.hpp>
22 #include <cereal/archives/xml.hpp>
23 #include <cereal/archives/json.hpp>
24 
25 namespace cereal {
26 
27 template<typename Archive>
29 {
30  // Archive::is_saving is not implemented yet, so we can use std::is_same<>
31  // to check if it is a loading archive.
32  constexpr static bool value = std::is_same<Archive,
33  cereal::BinaryOutputArchive>::value ||
34 // #if (BINDING_TYPE != BINDING_TYPE_R)
35  std::is_same<Archive, cereal::JSONOutputArchive>::value ||
36 // #endif
37  std::is_same<Archive, cereal::XMLOutputArchive>::value;
38 };
39 
40 template<typename Archive>
41 bool is_saving(
42  const typename std::enable_if<
43  is_cereal_archive_saving<Archive>::value, Archive>::type* = 0)
44 {
45  return true;
46 }
47 
48 template<typename Archive>
49 bool is_saving(
50  const typename std::enable_if<
51  !is_cereal_archive_saving<Archive>::value, Archive>::type* = 0)
52 {
53  return false;
54 }
55 
56 } // namespace cereal
57 
58 #endif // CEREAL_IS_SAVING_HPP
bool is_saving(const typename std::enable_if< is_cereal_archive_saving< Archive >::value, Archive >::type *=0)
Definition: is_saving.hpp:41
static constexpr bool value
Definition: is_saving.hpp:32