text:
// Boost.Geometry

// Copyright (c) 2017-2020, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle

// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html

#ifndef BOOST_GEOMETRY_STRATEGIES_DENSIFY_HPP
#define BOOST_GEOMETRY_STRATEGIES_DENSIFY_HPP

#include <boost/geometry/core/static_assert.hpp>

namespace boost { namespace geometry
{

namespace strategy { namespace densify
{

namespace services
{

template <typename CSTag>
struct default_strategy
{
    BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
        "Not implemented for this coordinate system.",
        CSTag);
};

} // namespace services

}} // namespace strategy::densify

}} // namespace boost::geometry

#endif // BOOST_GEOMETRY_STRATEGIES_DENSIFY_HPP

ext: hpp


text:
#include <memo/cli/KeyValueStore.hh>

#include <boost/range/adaptor/transformed.hpp>

#include <elle/reactor/network/resolve.hh>

#include <memo/cli/Memo.hh>
#include <memo/cli/utility.hh>
#include <memo/grpc/grpc.hh>
#include <memo/grpc/memo_vs.hh>
#include <memo/kvs/lib/libkvs.h>
#include <memo/model/doughnut/Doughnut.hh>
#include <memo/model/doughnut/Local.hh>
#include <memo/silo/Silo.hh>

ELLE_LOG_COMPONENT("cli.key-value-store");

using boost::adaptors::transformed;

namespace memo
{
  namespace cli
  {
    KeyValueStore::KeyValueStore(Memo& cli)
      : Object(cli)
      , create(*this,
               "Create a key-value store",
               cli::name,
               cli::network,
               cli::description = boost::none,
               cli::push_key_value_store = false,
               cli::output = boost::none,
               cli::push = false)
      , delete_(*this,
                "Delete a key-value store locally",
                cli::name,
                cli::pull = false,
                cli::purge = false)
      , export_(*this,
                "Export a key-value store for someone else to import",
                cli::name,
                cli::output = boost::none)
      , fetch(*this,
              "Fetch a key-value store from {hub}",
              cli::name = boost::none,
              cli::network = boost::none)
      , import(*this,
               "Import a key-value store",
               cli::input = boost::none)
      , list(*this, "List key-value stores")
      , pull(*this,
             "Remove a key-value store from {hub}",
             cli::name,
             cli::purge = false)
      , push(*this,
             "Push a key-value store to {hub}",
             cli::name)
      , run(*this,
            "Run a key-value store",
            cli::name,
            cli::grpc,
            cli::allow_root_creation = false,
            cli::peer = Strings{},
            cli::async = false,
            cli::cache = false,
            cli::cache_ram_size = boost::none,
            cli::cache_ram_ttl = boost::none,
            cli::cache_ram_invalidation = boost::none,
            cli::cache_disk_size = boost::none,
            cli::fetch_endpoints = false,
            cli::fetch = false,
            cli::push_endpoints = false,
            cli::push = false,
            cli::publish = false,
            cli::endpoints_file = boost::none,
            cli::peers_file = boost::none,
            cli::port = boost::none,
            cli::listen = boost::none,
            cli::fetch_endpoints_interval = boost::none,
            cli::no_local_endpoints = false,
            cli::no_public_endpoints = false,
            cli::advertise_host = Strings{},
            cli::grpc_port_file = boost::none)
    {}

    /*---------------.
    | Mode: create.  |
    `---------------*/

    void
    KeyValueStore::mode_create(std::string const& unqualified_name,
                               std::string const& network_name,
                               boost::optional<std::string> description,
                               bool push_key_value_store,
                               boost::optional<std::string> output_name,
                               bool push)
    {
      ELLE_TRACE_SCOPE("create");
      auto& cli = this->cli();
      auto& memo = cli.backend();
      auto owner = cli.as_user();
      auto name = memo.qualified_name(unqualified_name, owner);
      auto network = memo.network_get(network_name, owner);

      auto kvs = memo::KeyValueStore(name, network.name, description);
      if (output_name)
      {
        auto output = cli.get_output(output_name);
        auto s = elle::serialization::json::SerializerOut(*output, false);
        s.serialize_forward(kvs);
      }
      else
      {
        memo.key_value_store_save(kvs);
      }
      if (push || push_key_value_store)
        memo.hub_push("kvs", name, kvs, owner);
    }

    /*---------------.
    | Mode: delete.  |
    `---------------*/

    void
    KeyValueStore::mode_delete(std::string const& unqualified_name,
                               bool pull,
                               bool purge)
    {
      ELLE_TRACE_SCOPE("delete");
      auto& cli = this->cli();
      auto& memo = cli.backend();
      auto owner = cli.as_user();
      auto name = memo.qualified_name(unqualified_name, owner);
      auto kvs = memo.key_value_store_get(name);
      if (purge)
      { /* Do nothing */ }
      if (pull)
        memo.hub_delete("kvs", name, owner, true, purge);
      memo.key_value_store_delete(kvs);
    }

    /*---------------.
    | Mode: export.  |
    `---------------*/

    void
    KeyValueStore::mode_export(std::string const& unqualified_name,
                               boost::optional<std::string> const& output_name)
    {
      ELLE_TRACE_SCOPE("export");
      auto& cli = this->cli();
      auto& memo = cli.backend();
      auto owner = cli.as_user();
      auto name = memo.qualified_name(unqualified_name, owner);
      auto kvs = memo.key_value_store_get(name);
      auto output = cli.get_output(output_name);
      {
        auto s = elle::serialization::json::SerializerOut(*output, false);
        s.serialize_forward(kvs);
      }
      cli.report_exported(*output, "kvs", kvs.name);
    }

    /*--------------.
    | Mode: fetch.  |
    `--------------*/

    void
    KeyValueStore::mode_fetch(boost::optional<std::string> unqualified_name,
                              boost::optional<std::string> network_name)
    {
      ELLE_TRACE_SCOPE("fetch");
      auto& cli = this->cli();
      auto& memo = cli.backend();
      auto owner = cli.as_user();
      using KeyValueStoresMap
        = std::unordered_map<std::string, std::vector<memo::KeyValueStore>>;
      if (unqualified_name)
      {
        auto name = memo.qualified_name(*unqualified_name, owner);
        auto desc =
          memo.hub_fetch<memo::KeyValueStore>("kvs", name);
        memo.key_value_store_save(std::move(desc));
      }
      else if (network_name)
      {
        // Fetch all key-value stores for network.
        auto net_name = memo.qualified_name(*network_name, owner);
        auto res = memo.hub_fetch<KeyValueStoresMap>(
            elle::sprintf("networks/%s/kvs", net_name),
            "kvs for network",
            net_name);
        for (auto const& k: res["kvs"])
          memo.key_value_store_save(k);
      }
      else
      {
        // Fetch all key-value stores for owner.
        auto res = memo.hub_fetch<KeyValueStoresMap>(
            elle::sprintf("users/%s/kvs", owner.name),
            "kvs for user",
            owner.name,
            owner);
        for (auto const& k: res["kvs"])
          memo.key_value_store_save(k, true);
      }
    }

    /*---------------.
    | Mode: import.  |
    `---------------*/

    void
    KeyValueStore::mode_import(boost::optional<std::string> input_name)
    {
      ELLE_TRACE_SCOPE("import");
      auto& cli = this->cli();
      auto& memo = cli.backend();
      auto input = this->cli().get_input(input_name);
      auto s = elle::serialization::json::SerializerIn(*input, false);
      auto kvs = memo::KeyValueStore(s);
      memo.key_value_store_save(kvs);
      cli.report_imported("kvs", kvs.name);
    }

    /*-------------.
    | Mode: list.  |
    `-------------*/

    void
    KeyValueStore::mode_list()
    {
      ELLE_TRACE_SCOPE("list");
      auto& cli = this->cli();
      auto& memo = cli.backend();

      if (cli.script())
      {
        auto const l = elle::json::Json(
          memo.key_value_stores_get() | transformed(
            [&](auto const& kvs)
            {
              auto res = elle::json::Json
                {
                  {"name", static_cast<std::string>(kvs.name)},
                  {"network", kvs.network},
                };
              if (kvs.description)
                res["description"] = *kvs.description;
              return res;
            }));
        elle::json::write(std::cout, l);
      }
      else
        for (auto const& k: memo.key_value_stores_get())
        {
          std::cout << k.name;
          if (k.description)
            std::cout << " \"" << k.description.get() << "\"";
          std::cout << ": network " << k.network;
          std::cout << std::endl;
        }
    }

    /*-------------.
    | Mode: pull.  |
    `-------------*/

    void
    KeyValueStore::mode_pull(std::string const& unqualified_name,
                             bool purge)
    {
      ELLE_TRACE_SCOPE("pull");
      auto& cli = this->cli();
      auto& memo = cli.backend();
      auto owner = cli.as_user();
      auto const name = memo.qualified_name(unqualified_name, owner);
      memo.hub_delete("kvs", name, owner, false, purge);
    }

    /*-------------.
    | Mode: push.  |
    `-------------*/

    void
    KeyValueStore::mode_push(std::string const& unqualified_name)
    {
      ELLE_TRACE_SCOPE("push");
      auto& cli = this->cli();
      auto& memo = cli.backend();
      auto owner = cli.as_user();
      auto const name = memo.qualified_name(unqualified_name, owner);
      auto kvs = memo.key_value_store_get(name);
      auto network = memo.network_get(kvs.network, owner);
      memo.hub_push("kvs", name, kvs, owner);
    }

    /*------------.
    | Mode: run.  |
    `------------*/

    void
    KeyValueStore::mode_run(std::string const& unqualified_name,
                            std::string const& grpc,
                            bool allow_root_creation,
                            Strings peer,
                            bool async,
                            bool cache,
                            boost::optional<int> cache_ram_size,
                            boost::optional<int> cache_ram_ttl,
                            boost::optional<int> cache_ram_invalidation,
                            boost::optional<uint64_t> cache_disk_size,
                            bool fetch_endpoints,
                            bool fetch,
                            bool push_endpoints,
                            bool push,
                            bool publish,
                            boost::optional<std::string> const& endpoints_file,
                            boost::optional<std::string> const& peers_file,
                            boost::optional<int> port,
                            boost::optional<std::string> listen,
                            boost::optional<int> fetch_endpoints_interval,
                            bool no_local_endpoints,
                            bool no_public_endpoints,
                            Strings advertise_host,
                            boost::optional<std::string> grpc_port_file)
    {
      ELLE_TRACE_SCOPE("run");
      auto& cli = this->cli();
      auto& memo = cli.backend();
      auto owner = cli.as_user();
      auto const name = memo.qualified_name(unqualified_name, owner);
      auto kvs = memo.key_value_store_get(name);
      auto network = memo.network_get(kvs.network, owner);

      network.ensure_allowed(owner, "run", "kvs");
      cache |= (cache_ram_size || cache_ram_ttl
                || cache_ram_invalidation || cache_disk_size);
      auto const listen_address
        = listen
        ? boost::asio::ip::address::from_string(*listen)
        : boost::optional<boost::asio::ip::address>{};
      auto dht = network.run(
        owner,
        false,
        cache, cache_ram_size, cache_ram_ttl, cache_ram_invalidation,
        async, cache_disk_size, cli.compatibility_version(),
        port,
        listen_address);
      hook_stats_signals(*dht);
      int dht_grpc_port = 0;
      auto dht_grpc_thread = std::make_unique<elle::reactor::Thread>
        ("DHT gRPC",
        [dht = dht.get(), &dht_grpc_port] {
          memo::grpc::serve_memo_vs(*dht,
            "127.0.0.1:0", &dht_grpc_port);
        });
      // Wait for DHT gRPC server to be running.
      while (dht_grpc_port == 0)
        elle::reactor::sleep(100ms);
      if (peers_file)
      {
        auto more_peers = hook_peer_discovery(*dht, *peers_file);
        ELLE_TRACE("Peer list file got %s peers", more_peers.size());
        if (!more_peers.empty())
          dht->overlay()->discover(more_peers);
      }
      if (!peer.empty())
        dht->overlay()->discover(parse_peers(peer));
      // Only push if we have are contributing storage.
      bool push_p = (push || publish)
        && dht->local() && dht->local()->storage();
      if (!dht->local() && push_p)
        elle::err("network %s is client only since no storage is attached",
                  name);
      if (dht->local() && endpoints_file)
        endpoints_to_file(dht->local()->server_endpoints(), *endpoints_file);
      auto run = [&]
        {
          elle::reactor::Thread::unique_ptr poll_thread;
          if (fetch || publish)
          {
            memo::model::NodeLocations eps;
            network.hub_fetch_endpoints(eps);
            dht->overlay()->discover(eps);
            if (fetch_endpoints_interval && *fetch_endpoints_interval > 0)
              poll_thread =
                network.make_poll_hub_thread(*dht, eps,
                                             *fetch_endpoints_interval);
          }
        };
      if (push_p)
        elle::With<InterfacePublisher>(
          memo,
          network, owner, dht->id(),
          dht->local()->server_endpoint().port(),
          advertise_host,
          no_local_endpoints,
          no_public_endpoints) << [&]
          {
            run();
          };
      else
        run();
      cli.report_action("running", "network", network.name);
      auto dht_ep = elle::sprintf("127.0.0.1:%s", dht_grpc_port);
      auto go_str = [] (std::string const& str) {
        return GoString{str.c_str(), static_cast<GoInt>(str.size())};
      };
      GoInt kv_grpc_port = 0;
      auto port_writer_thread = std::unique_ptr<elle::reactor::Thread>();
      elle::With<elle::Finally>([&]
      {
        if (grpc_port_file)
        {
          boost::system::error_code ec;
          bfs::remove(bfs::path(*grpc_port_file), ec);
        }
      }) << [&] (elle::Finally& f)
      {
        if (grpc_port_file)
        {
          port_writer_thread.reset(new elle::reactor::Thread(
            elle::reactor::scheduler(),
            "port file writer",
            [&] {
              while (kv_grpc_port == 0)
                elle::reactor::sleep(100ms);
              port_to_file(kv_grpc_port, *grpc_port_file);
            }));
        }
        static const auto signals = {SIGINT, SIGTERM
#ifndef ELLE_WINDOWS
                                     , SIGQUIT
#endif
        };
        for (auto s: signals)
          elle::reactor::scheduler().signal_handle(
            s,
            []
            {
              ELLE_DEBUG("stopping kvs");
              StopServer();
            });
        elle::reactor::background([&] {
          cli.report_action("running", "kvs", name);
          RunServer(
            go_str(name), go_str(dht_ep), go_str(grpc), allow_root_creation,
            &kv_grpc_port);
        });
      };
    }
  }
}

ext: cc

max_stars_repo_name: infinit/memo

max_issues_repo_name: infinit/memo

max_forks_repo_name: infinit/memo


text: #include <boost/numeric/odeint/stepper/controlled_step_result.hpp>

max_stars_repo_name: miathedev/BoostForArduino

max_issues_repo_name: miathedev/BoostForArduino

max_forks_repo_name: miathedev/BoostForArduino


text:
// unit test file sinc.hpp for the special functions test suite

//  (C) Copyright Hubert Holin 2003. Permission to copy, use, modify, sell and
//  distribute this software is granted provided this copyright notice appears
//  in all copies. This software is provided "as is" without express or implied
//  warranty, and with no claim as to its suitability for any purpose.

#include <functional>
#include <iomanip>
#include <iostream>
#include <complex>

#include <boost/math/special_functions/sinc.hpp>

#include <boost/test/unit_test.hpp>

template<typename T>
void    sinc_pi_test(const char * more_blurb)
{
    using    ::std::abs;

    using    ::std::numeric_limits;

    using    ::boost::math::sinc_pi;

    BOOST_MESSAGE("Testing sinc_pi in the real domain for "
        << more_blurb << ".");

    BOOST_CHECK_PREDICATE(::std::less_equal<T>(), 2,
        (
            abs(sinc_pi<T>(static_cast<T>(0))-static_cast<T>(1)),
            numeric_limits<T>::epsilon()
        ));
}

template<typename T>
void    sinc_pi_complex_test(const char * more_blurb)
{
    using    ::std::abs;
    using    ::std::sinh;

    using    ::std::numeric_limits;

    using    ::boost::math::sinc_pi;

    BOOST_MESSAGE("Testing sinc_pi in the complex domain for "
        << more_blurb << ".");

    BOOST_CHECK_PREDICATE(::std::less_equal<T>(), 2,
        (
            abs(sinc_pi<T>(::std::complex<T>(0, 1))-
                ::std::complex<T>(sinh(static_cast<T>(1)))),
            numeric_limits<T>::epsilon()
        ));
}

void    sinc_pi_manual_check()
{
    using    ::boost::math::sinc_pi;

    BOOST_MESSAGE("sinc_pi");

    for    (int i = 0; i <= 100; i++)
    {
        BOOST_MESSAGE( ::std::setw(15)
                    << sinc_pi<float>(static_cast<float>(i-50)/
                                                static_cast<float>(50))
                    << ::std::setw(15)
                    << sinc_pi<double>(static_cast<double>(i-50)/
                                                static_cast<double>(50))
                    << ::std::setw(15)
                    << sinc_pi<long double>(static_cast<long double>(i-50)/
                                                static_cast<long double>(50)));
    }

    BOOST_MESSAGE(" ");
}


text:
//  filesystem path_unit_test.cpp  ---------------------------------------------------  //

//  Copyright Beman Dawes 2008, 2009

//  Distributed under the Boost Software License, Version 1.0.
//  See http://www.boost.org/LICENSE_1_0.txt

//  Library home page: http://www.boost.org/libs/filesystem

//  ----------------------------------------------------------------------------------  //
//
//  The purpose of this test is to ensure that each function in the public
//  interface can be called with arguments of the appropriate types. It does
//  not attempt to verify that the full range of values for each argument
//  are processed correctly.
//
//  For full functionality tests, including probes with many different argument
//  values, see path_test.cpp and other test programs.
//
//  ----------------------------------------------------------------------------------  //

#define BOOST_FILESYSTEM_VERSION 3

#include <boost/config.hpp>

# if defined( BOOST_NO_STD_WSTRING )
#   error Configuration not supported: Boost.Filesystem V3 and later requires std::wstring support
# endif

#include <boost/config/warning_disable.hpp>

//  See deprecated_test for tests of deprecated features
#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
# define BOOST_FILESYSTEM_NO_DEPRECATED
#endif
#ifndef BOOST_SYSTEM_NO_DEPRECATED
# define BOOST_SYSTEM_NO_DEPRECATED
#endif

#include <boost/filesystem/path.hpp>
#include <boost/filesystem/detail/utf8_codecvt_facet.hpp>  // for imbue tests
#include "test_codecvt.hpp"                                // for codecvt arg tests
#include <boost/detail/lightweight_test.hpp>
#include <boost/detail/lightweight_main.hpp>
#include <boost/smart_ptr.hpp>  // used constructor tests
#include <boost/functional/hash.hpp>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <cstring>
#include <cwchar>
#include <locale>
#include <list>

namespace fs = boost::filesystem;
namespace bs = boost::system;
using boost::filesystem::path;
using std::cout;
using std::endl;
using std::string;
using std::wstring;

#define CHECK(x) check(x, __FILE__, __LINE__)
#define PATH_IS(a, b) check_path(a, b, __FILE__, __LINE__)
#define NATIVE_IS(p, s, ws) check_native(p, s, ws, __FILE__, __LINE__)
#define IS(a,b) check_equal(a, b, __FILE__, __LINE__)

#if defined(_MSC_VER)
# pragma warning(push) // Save warning settings.
# pragma warning(disable : 4428) // Disable universal-character-name encountered in source warning.
#endif

namespace
{

  boost::system::error_code ec;
  const boost::system::error_code ok;
  const boost::system::error_code ng(-1, boost::system::system_category());

  std::string platform(BOOST_PLATFORM);

  void check_path(const path& source,
              const wstring& expected, const char* file, int line)
  {
    if (source == expected) return;

    ++::boost::detail::test_errors();

    std::cout << file;
    std::wcout << L'(' << line << L"): source.wstring(): \""
               << source.wstring()
               << L"\" != expected: \"" << expected
               << L"\"\n" ;
  }

# ifdef BOOST_WINDOWS_API
  void check_native(const path& p,
    const string&, const wstring& expected, const char* file, int line)
# else
  void check_native(const path& p,
    const string& expected, const wstring&, const char* file, int line)
# endif
  {
    if (p.native() == expected) return;

    ++::boost::detail::test_errors();

    std::cout << file  << '(' << line << "): native() is not equal expected\n"
      "  native---: " << std::hex;
    path::string_type nat(p.native());
    for (path::string_type::const_iterator it = nat.begin(); it != nat.end(); ++it)
      std::cout << long(*it) << ' ';
    std::cout << "\n  expected-: ";
    for (path::string_type::const_iterator it = expected.begin(); it != expected.end(); ++it)
      std::cout << long(*it) << ' ';
    std::cout << std::dec << std::endl;
  }

  template< class T1, class T2 >
  void check_equal(const T1& value,
                    const T2& expected, const char* file, int line)
  {
    if (value == expected) return;

    ++::boost::detail::test_errors();

    std::cout << file;

    std::wcout << L'(' << line << L"): value: \"" << value
               << L"\" != expected: \"" << expected
               << L"\"\n" ;
  }

  void check(bool ok, const char* file, int line)
  {
    if (ok) return;

    ++::boost::detail::test_errors();

    std::cout << file << '(' << line << "): test failed\n";
  }

  string s("string");
  wstring ws(L"wstring");
  std::list<char> l;      // see main() for initialization to s, t, r, i, n, g
  std::list<wchar_t> wl;  // see main() for initialization to w, s, t, r, i, n, g
  std::vector<char> v;      // see main() for initialization to f, u, z
  std::vector<wchar_t> wv;  // see main() for initialization to w, f, u, z

  class Base {};
  class Derived : public Base {};
  void fun(const boost::filesystem::path&) {}
  void fun(const boost::shared_ptr< Base >&) {}

  //  test_constructors  ---------------------------------------------------------------//

  void test_constructors()
  {
    std::cout << "testing constructors..." << std::endl;

    path x0;                                           // default constructor
    PATH_IS(x0, L"");
    BOOST_TEST_EQ(x0.native().size(), 0U);

    path x1(l.begin(), l.end());                       // iterator range char
    PATH_IS(x1, L"string");
    BOOST_TEST_EQ(x1.native().size(), 6U);

    path x2(x1);                                       // copy constructor
    PATH_IS(x2, L"string");
    BOOST_TEST_EQ(x2.native().size(), 6U);

    path x3(wl.begin(), wl.end());                     // iterator range wchar_t
    PATH_IS(x3, L"wstring");
    BOOST_TEST_EQ(x3.native().size(), 7U);

    // contiguous containers
    path x4(string("std::string"));                    // std::string
    PATH_IS(x4, L"std::string");
    BOOST_TEST_EQ(x4.native().size(), 11U);

    path x5(wstring(L"std::wstring"));                 // std::wstring
    PATH_IS(x5, L"std::wstring");
    BOOST_TEST_EQ(x5.native().size(), 12U);

    path x4v(v);                                       // std::vector<char>
    PATH_IS(x4v, L"fuz");
    BOOST_TEST_EQ(x4v.native().size(), 3U);

    path x5v(wv);                                      // std::vector<wchar_t>
    PATH_IS(x5v, L"wfuz");
    BOOST_TEST_EQ(x5v.native().size(), 4U);

    path x6("array char");                             // array char
    PATH_IS(x6, L"array char");
    BOOST_TEST_EQ(x6.native().size(), 10U);

    path x7(L"array wchar_t");                         // array wchar_t
    PATH_IS(x7, L"array wchar_t");
    BOOST_TEST_EQ(x7.native().size(), 13U);

    char char_array[100];
    std::strcpy(char_array, "big array char");
    path x6o(char_array);                              // array char, only partially full
    PATH_IS(x6o, L"big array char");
    BOOST_TEST_EQ(x6o.native().size(), 14U);

    wchar_t wchar_array[100];
    std::wcscpy(wchar_array, L"big array wchar_t");
    path x7o(wchar_array);                             // array char, only partially full
    PATH_IS(x7o, L"big array wchar_t");
    BOOST_TEST_EQ(x7o.native().size(), 17U);

    path x8(s.c_str());                                // const char* null terminated
    PATH_IS(x8, L"string");
    BOOST_TEST_EQ(x8.native().size(), 6U);

    path x9(ws.c_str());                               // const wchar_t* null terminated
    PATH_IS(x9, L"wstring");
    BOOST_TEST_EQ(x9.native().size(), 7U);

    // non-contiguous containers
    path x10(l);                                       // std::list<char>
    PATH_IS(x10, L"string");
    BOOST_TEST_EQ(x10.native().size(), 6U);

    path xll(wl);                                      // std::list<wchar_t>
    PATH_IS(xll, L"wstring");
    BOOST_TEST_EQ(xll.native().size(), 7U);

    // easy-to-make coding errors
    // path e1(x0, path::codecvt());  // fails to compile, and that is OK

    boost::shared_ptr< Derived > pDerived( new Derived() );
    fun( pDerived );  // tests constructor member template enable_if working correctly;
                      // will fail to compile if enable_if not taking path off the table
  }

  path x;
  path y;

  //  test_assignments  ----------------------------------------------------------------//

  void test_assignments()
  {
    std::cout << "testing assignments..." << std::endl;

    x = path("yet another path");                      // another path
    PATH_IS(x, L"yet another path");
    BOOST_TEST_EQ(x.native().size(), 16U);

    x = x;                                             // self-assignment
    PATH_IS(x, L"yet another path");
    BOOST_TEST_EQ(x.native().size(), 16U);

    x.assign(l.begin(), l.end());                      // iterator range char
    PATH_IS(x, L"string");

    x.assign(wl.begin(), wl.end());                    // iterator range wchar_t
    PATH_IS(x, L"wstring");

    x = string("std::string");                         // container char
    PATH_IS(x, L"std::string");

    x = wstring(L"std::wstring");                      // container wchar_t
    PATH_IS(x, L"std::wstring");

    x = "array char";                                  // array char
    PATH_IS(x, L"array char");

    x = L"array wchar";                                // array wchar_t
    PATH_IS(x, L"array wchar");

    x = s.c_str();                                     // const char* null terminated
    PATH_IS(x, L"string");

    x = ws.c_str();                                    // const wchar_t* null terminated
    PATH_IS(x, L"wstring");
   }

  //  test_appends  --------------------------------------------------------------------//

  void test_appends()
  {
    std::cout << "testing appends..." << std::endl;

# ifdef BOOST_WINDOWS_API
#   define BOOST_FS_FOO L"/foo\\"
# else   // POSIX paths
#   define BOOST_FS_FOO L"/foo/"
# endif

    x = "/foo";
    x /= path("");                                      // empty path
    PATH_IS(x, L"/foo");

    x = "/foo";
    x /= path("/");                                     // slash path
    PATH_IS(x, L"/foo/");

    x = "/foo";
    x /= path("/boo");                                  // slash path
    PATH_IS(x, L"/foo/boo");

    x = "/foo";
    x /= x;                                             // self-append
    PATH_IS(x, L"/foo/foo");

    x = "/foo";
    x /= path("yet another path");                      // another path
    PATH_IS(x, BOOST_FS_FOO L"yet another path");

    x = "/foo";
    x.append(l.begin(), l.end());                      // iterator range char
    PATH_IS(x, BOOST_FS_FOO L"string");

    x = "/foo";
    x.append(wl.begin(), wl.end());                    // iterator range wchar_t
    PATH_IS(x, BOOST_FS_FOO L"wstring");

    x = "/foo";
    x /= string("std::string");                         // container char
    PATH_IS(x, BOOST_FS_FOO L"std::string");

    x = "/foo";
    x /= wstring(L"std::wstring");                      // container wchar_t
    PATH_IS(x, BOOST_FS_FOO L"std::wstring");

    x = "/foo";
    x /= "array char";                                  // array char
    PATH_IS(x, BOOST_FS_FOO L"array char");

    x = "/foo";
    x /= L"array wchar";                                // array wchar_t
    PATH_IS(x, BOOST_FS_FOO L"array wchar");

    x = "/foo";
    x /= s.c_str();                                     // const char* null terminated
    PATH_IS(x, BOOST_FS_FOO L"string");

    x = "/foo";
    x /= ws.c_str();                                    // const wchar_t* null terminated
    PATH_IS(x, BOOST_FS_FOO L"wstring");
   }

  //  test_observers  ------------------------------------------------------------------//

  void test_observers()
  {
    std::cout << "testing observers..." << std::endl;

    path p0("abc");

    CHECK(p0.native().size() == 3);
    CHECK(p0.string() == "abc");
    CHECK(p0.string().size() == 3);
    CHECK(p0.wstring() == L"abc");
    CHECK(p0.wstring().size() == 3);

# ifdef BOOST_WINDOWS_API

    path p("abc\\def/ghi");

    CHECK(std::wstring(p.c_str()) == L"abc\\def/ghi");

    CHECK(p.string() == "abc\\def/ghi");
    CHECK(p.wstring() == L"abc\\def/ghi");

    CHECK(p.generic_string() == "abc/def/ghi");
    CHECK(p.generic_wstring() == L"abc/def/ghi");

    CHECK(p.generic_string<string>() == "abc/def/ghi");
    CHECK(p.generic_string<wstring>() == L"abc/def/ghi");
    CHECK(p.generic_string<path::string_type>() == L"abc/def/ghi");

# else  // BOOST_POSIX_API

    path p("abc\\def/ghi");

    CHECK(string(p.c_str()) == "abc\\def/ghi");

    CHECK(p.string() == "abc\\def/ghi");
    CHECK(p.wstring() == L"abc\\def/ghi");

    CHECK(p.generic_string() == "abc\\def/ghi");
    CHECK(p.generic_wstring() == L"abc\\def/ghi");

    CHECK(p.generic_string<string>() == "abc\\def/ghi");
    CHECK(p.generic_string<wstring>() == L"abc\\def/ghi");
    CHECK(p.generic_string<path::string_type>() == "abc\\def/ghi");

# endif
  }

  //  test_relationals  ----------------------------------------------------------------//

  void test_relationals()
  {
    std::cout << "testing relationals..." << std::endl;

    boost::hash<path> hash;

# ifdef BOOST_WINDOWS_API
    // this is a critical use case to meet user expectations
    CHECK(path("c:\\abc") == path("c:/abc"));
    CHECK(hash(path("c:\\abc")) == hash(path("c:/abc")));
# endif

    const path p("bar");
    const path p2("baz");

    CHECK(!(p < p));
    CHECK(p < p2);
    CHECK(!(p2 < p));
    CHECK(p < "baz");
    CHECK(p < string("baz"));
    CHECK(p < L"baz");
    CHECK(p < wstring(L"baz"));
    CHECK(!("baz" < p));
    CHECK(!(string("baz") < p));
    CHECK(!(L"baz" < p));
    CHECK(!(wstring(L"baz") < p));

    CHECK(p == p);
    CHECK(!(p == p2));
    CHECK(!(p2 == p));
    CHECK(p2 == "baz");
    CHECK(p2 == string("baz"));
    CHECK(p2 == L"baz");
    CHECK(p2 == wstring(L"baz"));
    CHECK("baz" == p2);
    CHECK(string("baz") == p2);
    CHECK(L"baz" == p2);
    CHECK(wstring(L"baz") == p2);

    CHECK(hash(p) == hash(p));
    CHECK(hash(p) != hash(p2)); // Not strictly required, but desirable

    CHECK(!(p != p));
    CHECK(p != p2);
    CHECK(p2 != p);

    CHECK(p <= p);
    CHECK(p <= p2);
    CHECK(!(p2 <= p));

    CHECK(!(p > p));
    CHECK(!(p > p2));
    CHECK(p2 > p);

    CHECK(p >= p);
    CHECK(!(p >= p2));
    CHECK(p2 >= p);
}

  //  test_inserter_and_extractor  -----------------------------------------------------//

  void test_inserter_and_extractor()
  {
    std::cout << "testing inserter and extractor..." << std::endl;

    path p1("foo bar");  // verify space in path roundtrips per ticket #3863
    path p2;

    std::stringstream ss;

    CHECK(p1 != p2);
    ss << p1;
    ss >> p2;
    CHECK(p1 == p2);

    path wp1(L"foo bar");
    path wp2;

    std::wstringstream wss;

    CHECK(wp1 != wp2);
    wss << wp1;
    wss >> wp2;
    CHECK(wp1 == wp2);
  }

  //  test_other_non_members  ----------------------------------------------------------//

  void test_other_non_members()
  {
    std::cout << "testing other_non_members..." << std::endl;

    path p1("foo");
    path p2("bar");

    //  operator /

    CHECK(p1 / p2 == path("foo/bar").make_preferred());
    CHECK("foo" / p2 == path("foo/bar").make_preferred());
    CHECK(L"foo" / p2 == path("foo/bar").make_preferred());
    CHECK(string("foo") / p2 == path("foo/bar").make_preferred());
    CHECK(wstring(L"foo") / p2 == path("foo/bar").make_preferred());
    CHECK(p1 / "bar" == path("foo/bar").make_preferred());
    CHECK(p1 / L"bar" == path("foo/bar").make_preferred());
    CHECK(p1 / string("bar") == path("foo/bar").make_preferred());
    CHECK(p1 / wstring(L"bar") == path("foo/bar").make_preferred());

    swap(p1, p2);

    CHECK(p1 == "bar");
    CHECK(p2 == "foo");

    CHECK(path("").remove_filename() == "");
    CHECK(path("foo").remove_filename() == "");
    CHECK(path("foo/bar").remove_filename() == "foo");
  }

//  //  test_modifiers  ------------------------------------------------------------------//
//
//  void test_modifiers()
//  {
//    std::cout << "testing modifiers..." << std::endl;
//
//  }

  //  test_iterators  ------------------------------------------------------------------//

  void test_iterators()
  {
    std::cout << "testing iterators..." << std::endl;

    path p1;
    CHECK(p1.begin() == p1.end());

    path p2("/");
    CHECK(p2.begin() != p2.end());
    CHECK(*p2.begin() == "/");
    CHECK(++p2.begin() == p2.end());

    path p3("foo/bar/baz");

    path::iterator it(p3.begin());
    CHECK(p3.begin() != p3.end());
    CHECK(*it == "foo");
    CHECK(*++it == "bar");
    CHECK(*++it == "baz");
    CHECK(*--it == "bar");
    CHECK(*--it == "foo");
    CHECK(*++it == "bar");
    CHECK(*++it == "baz");
    CHECK(++it == p3.end());
  }

  //  test_modifiers  ------------------------------------------------------------------//

  void test_modifiers()
  {
    std::cout << "testing modifiers..." << std::endl;

  }

  //  test_decompositions  -------------------------------------------------------------//

  void test_decompositions()
  {
    std::cout << "testing decompositions..." << std::endl;

    CHECK(path("").root_name().string() == "");
    CHECK(path("foo").root_name().string() == "");
    CHECK(path("/").root_name().string() == "");
    CHECK(path("/foo").root_name().string() == "");
    CHECK(path("//netname").root_name().string() == "//netname");
    CHECK(path("//netname/foo").root_name().string() == "//netname");

    CHECK(path("").root_directory().string() == "");
    CHECK(path("foo").root_directory().string() == "");
    CHECK(path("/").root_directory().string() == "/");
    CHECK(path("/foo").root_directory().string() == "/");
    CHECK(path("//netname").root_directory().string() == "");
    CHECK(path("//netname/foo").root_directory().string() == "/");

    CHECK(path("").root_path().string() == "");
    CHECK(path("/").root_path().string() == "/");
    CHECK(path("/foo").root_path().string() == "/");
    CHECK(path("//netname").root_path().string() == "//netname");
    CHECK(path("//netname/foo").root_path().string() == "//netname/");

#   ifdef BOOST_WINDOWS_API
    CHECK(path("c:/foo").root_path().string() == "c:/");
#   endif

    CHECK(path("").relative_path().string() == "");
    CHECK(path("/").relative_path().string() == "");
    CHECK(path("/foo").relative_path().string() == "foo");

    CHECK(path("").parent_path().string() == "");
    CHECK(path("/").parent_path().string() == "");
    CHECK(path("/foo").parent_path().string() == "/");
    CHECK(path("/foo/bar").parent_path().string() == "/foo");

    CHECK(path("/foo/bar/baz.zoo").filename().string() == "baz.zoo");

    CHECK(path("/foo/bar/baz.zoo").stem().string() == "baz");
    CHECK(path("/foo/bar.woo/baz").stem().string() == "baz");

    CHECK(path("foo.bar.baz.tar.bz2").extension().string() == ".bz2");
    CHECK(path("/foo/bar/baz.zoo").extension().string() == ".zoo");
    CHECK(path("/foo/bar.woo/baz").extension().string() == "");
  }

  //  test_queries  --------------------------------------------------------------------//

  void test_queries()
  {
    std::cout << "testing queries..." << std::endl;

    path p1("");
    path p2("//netname/foo.doo");

    CHECK(p1.empty());
    CHECK(!p1.has_root_path());
    CHECK(!p1.has_root_name());
    CHECK(!p1.has_root_directory());
    CHECK(!p1.has_relative_path());
    CHECK(!p1.has_parent_path());
    CHECK(!p1.has_filename());
    CHECK(!p1.has_stem());
    CHECK(!p1.has_extension());
    CHECK(!p1.is_absolute());
    CHECK(p1.is_relative());

    CHECK(!p2.empty());
    CHECK(p2.has_root_path());
    CHECK(p2.has_root_name());
    CHECK(p2.has_root_directory());
    CHECK(p2.has_relative_path());
    CHECK(p2.has_parent_path());
    CHECK(p2.has_filename());
    CHECK(p2.has_stem());
    CHECK(p2.has_extension());
    CHECK(p2.is_absolute());
    CHECK(!p2.is_relative());

  }

  //  test_imbue_locale  ---------------------------------------------------------------//

  void test_imbue_locale()
  {
    std::cout << "testing imbue locale..." << std::endl;

    //  weak test case for before/after states since we don't know what characters the
    //  default locale accepts.
    path before("abc");

    //  So that tests are run with known encoding, use Boost UTF-8 codecvt
    //  \u2722 and \xE2\x9C\xA2 are UTF-16 and UTF-8 FOUR TEARDROP-SPOKED ASTERISK

    std::locale global_loc = std::locale();
    std::locale loc(global_loc, new fs::detail::utf8_codecvt_facet);
    std::cout << "  imbuing locale ..." << std::endl;
    std::locale old_loc = path::imbue(loc);

    std::cout << "  testing with the imbued locale ..." << std::endl;
    path p2("\xE2\x9C\xA2");
    CHECK(p2 == L"\u2722");
    CHECK(p2.wstring() == L"\u2722");

    std::cout << "  imbuing the original locale ..." << std::endl;
    path::imbue(old_loc);

    std::cout << "  testing with the original locale ..." << std::endl;
    path after("abc");
    CHECK(before == after);

    std::cout << "  locale testing complete" << std::endl;
  }

  //  test_codecvt_argument  -----------------------------------------------------------//

  void test_codecvt_argument()
  {
    std::cout << "testing codecvt arguments..." << std::endl;

    const char * c1 = "a1";
    const std::string s1(c1);
    const std::wstring ws1(L"b2");  // off-by-one mimics test_codecvt
    const std::string s2("y8");
    const std::wstring ws2(L"z9");

    test_codecvt cvt;  // produces off-by-one values that will always differ from
                       // the system's default locale codecvt facet

    int t = 0;

    //  constructors
    std::cout << "  constructors test " << ++t << std::endl;
    path p(c1, cvt);
    NATIVE_IS(p, s1, ws1);

    std::cout << "  test " << ++t << std::endl;
    path p1(s1.begin(), s1.end(), cvt);
    NATIVE_IS(p1, s1, ws1);

    std::cout << "  test " << ++t << std::endl;
    path p2(ws2, cvt);
    NATIVE_IS(p2, s2, ws2);

    std::cout << "  test " << ++t << std::endl;
    path p3(ws2.begin(), ws2.end(), cvt);
    NATIVE_IS(p3, s2, ws2);

    // path p2(p1, cvt);  // fails to compile, and that is OK

    //  assigns
    p1.clear();
    std::cout << "  assigns test " << ++t << std::endl;
    p1.assign(s1,cvt);
    NATIVE_IS(p1, s1, ws1);
    p1.clear();
    std::cout << "  test " << ++t << std::endl;
    p1.assign(s1.begin(), s1.end(), cvt);
    NATIVE_IS(p1, s1, ws1);
    // p1.assign(p, cvt);  // fails to compile, and that is OK

    //  appends
    p1.clear();
    std::cout << "  appends test " << ++t << std::endl;
    p1.append(s1,cvt);
    NATIVE_IS(p1, s1, ws1);
    p1.clear();
    std::cout << "  test " << ++t << std::endl;
    p1.append(s1.begin(), s1.end(), cvt);
    NATIVE_IS(p1, s1, ws1);
    // p1.append(p, cvt);  // fails to compile, and that is OK

    //  native observers
    std::cout << "  native observers test " << ++t << std::endl;
    CHECK(p.string<std::string>(cvt) == s1);
    std::cout << "  test " << ++t << std::endl;
    CHECK(p.string(cvt) == s1);
    std::cout << "  test " << ++t << std::endl;
    CHECK(p.string<std::wstring>(cvt) == ws1);
    std::cout << "  test " << ++t << std::endl;
    CHECK(p.wstring(cvt) == ws1);

    //  generic observers
    std::cout << "  generic observers test " << ++t << std::endl;
    CHECK(p.generic_string<std::string>(cvt) == s1);
    std::cout << "  test " << ++t << std::endl;
    CHECK(p.generic_string(cvt) == s1);
    std::cout << "  test " << ++t << std::endl;
    CHECK(p.generic_string<std::wstring>(cvt) == ws1);
    std::cout << "  test " << ++t << std::endl;
    CHECK(p.generic_wstring(cvt) == ws1);

    std::cout << "  codecvt arguments testing complete" << std::endl;
  }

  //  test_overloads  ------------------------------------------------------------------//

  void test_overloads()
  {
    std::cout << "testing overloads..." << std::endl;
    std::string s("hello");
    const char a[] = "goodbye";
    path p1(s);
    path p2(s.c_str());
    path p3(a);
    path p4("foo");

    std::wstring ws(L"hello");
    const wchar_t wa[] = L"goodbye";
    path wp1(ws);
    path wp2(ws.c_str());
    path wp3(wa);
    path wp4(L"foo");
  }

  //  test_error_handling  -------------------------------------------------------------//

  class error_codecvt
    : public std::codecvt< wchar_t, char, std::mbstate_t >
  {
  public:
    explicit error_codecvt()
        : std::codecvt<wchar_t, char, std::mbstate_t>() {}
  protected:

    virtual bool do_always_noconv() const throw() { return false; }
    virtual int do_encoding() const throw() { return 0; }

    virtual std::codecvt_base::result do_in(std::mbstate_t&,
      const char*, const char*, const char*&,
      wchar_t*, wchar_t*, wchar_t*&) const
    {
      static std::codecvt_base::result r = std::codecvt_base::noconv;
      if (r == std::codecvt_base::partial) r = std::codecvt_base::error;
      else if (r == std::codecvt_base::error) r = std::codecvt_base::noconv;
      else r = std::codecvt_base::partial;
      return r;
    }

    virtual std::codecvt_base::result do_out(std::mbstate_t &,
      const wchar_t*, const wchar_t*, const wchar_t*&,
      char*, char*, char*&) const
    {
      static std::codecvt_base::result r = std::codecvt_base::noconv;
      if (r == std::codecvt_base::partial) r = std::codecvt_base::error;
      else if (r == std::codecvt_base::error) r = std::codecvt_base::noconv;
      else r = std::codecvt_base::partial;
      return r;
    }

    virtual std::codecvt_base::result do_unshift(std::mbstate_t&,
        char*, char*, char* &) const  { return ok; }
    virtual int do_length(std::mbstate_t &,
      const char*, const char*, std::size_t) const  { return 0; }
    virtual int do_max_length() const throw () { return 0; }
  };

  void test_error_handling()
  {
    std::cout << "testing error handling..." << std::endl;

    std::locale global_loc = std::locale();
    std::locale loc(global_loc, new error_codecvt);
    std::cout << "  imbuing error locale ..." << std::endl;
    std::locale old_loc = path::imbue(loc);

    //  These tests rely on a path constructor that fails in the locale conversion.
    //  Thus construction has to call codecvt. Force that by using a narrow string
    //  for Windows, and a wide string for POSIX.
#   ifdef BOOST_WINDOWS_API
#     define STRING_FOO_ "foo"
#   else
#     define STRING_FOO_ L"foo"
#   endif

    {
      std::cout << "    testing std::codecvt_base::partial error..." << std::endl;
      bool exception_thrown (false);
      try { path(STRING_FOO_); }
      catch (const bs::system_error & ex)
      {
        exception_thrown = true;
        BOOST_TEST_EQ(ex.code(), bs::error_code(std::codecvt_base::partial,
          fs::codecvt_error_category()));
      }
      catch (...) { std::cout << "***** unexpected exception type *****" << std::endl; }
      BOOST_TEST(exception_thrown);
    }

    {
      std::cout << "    testing std::codecvt_base::error error..." << std::endl;
      bool exception_thrown (false);
      try { path(STRING_FOO_); }
      catch (const bs::system_error & ex)
      {
        exception_thrown = true;
        BOOST_TEST_EQ(ex.code(), bs::error_code(std::codecvt_base::error,
          fs::codecvt_error_category()));
      }
      catch (...) { std::cout << "***** unexpected exception type *****" << std::endl; }
      BOOST_TEST(exception_thrown);
    }

    {
      std::cout << "    testing std::codecvt_base::noconv error..." << std::endl;
      bool exception_thrown (false);
      try { path(STRING_FOO_); }
      catch (const bs::system_error & ex)
      {
        exception_thrown = true;
        BOOST_TEST_EQ(ex.code(), bs::error_code(std::codecvt_base::noconv,
          fs::codecvt_error_category()));
      }
      catch (...) { std::cout << "***** unexpected exception type *****" << std::endl; }
      BOOST_TEST(exception_thrown);
    }

    std::cout << "  restoring original locale ..." << std::endl;
    path::imbue(old_loc);
    std::cout << "  testing error handling complete" << std::endl;
 }

# if 0

//  //  test_locales  --------------------------------------------------------------------//
//
//  void test_locales()
//  {
//    std::cout << "testing locales..." << std::endl;
//
//  }

  //  test_user_supplied_type  ---------------------------------------------------------//

  typedef std::basic_string<int> user_string;

}  // unnamed namespace

namespace boost
{
namespace filesystem
{
  namespace path_traits
  {
    template<> struct is_iterator<const user_string::value_type *> { static const bool value = true; };
    template<> struct is_iterator<user_string::value_type *> { static const bool value = true; };
    template<> struct is_iterator<user_string::iterator> { static const bool value = true; };
    template<> struct is_iterator<user_string::const_iterator> { static const bool value = true; };
    template<> struct is_container<user_string> { static const bool value = true; };

    template<>
    void append<user_string::value_type>(const user_string::value_type * begin,
      const user_string::value_type * end, string_type & target, system::error_code & ec)
    {
      for (; begin != end && *begin; ++begin)
        target += *begin + 1;  // change so that results distinguishable from char cvts
    }

#  ifdef __GNUC__
    //  This specialization shouldn't be needed, and VC++, Intel, and others work
    //  fine without it. But gcc 4.3.2, and presumably other versions, need it.
    template<>
    void append<user_string::value_type>(const user_string::value_type * begin,
      string_type & target, system::error_code & ec)
    {
      path_traits::append<user_string::value_type>(begin,
        static_cast<const user_string::value_type *>(0), target, ec);
    }
#  endif

    template<>
    user_string convert<user_string>(const string_type & source,
      system::error_code & ec)
    {
      user_string temp;
      for (string_type::const_iterator it = source.begin();
            it != source.end(); ++it)
        temp += *it - 1;
      return temp;
    }
  }  // namespace path_traits
}  // namespace filesystem
}  // namespace boost

namespace
{

  void test_user_supplied_type()
  {
    std::cout << "testing user supplied type..." << std::endl;

    user_string::value_type usr_c_str[] = { 'a', 'b', 'c', 0 };
    user_string usr(usr_c_str);

    path p1(usr.c_str());
    CHECK(p1 == path("bcd"));
    CHECK(p1 == "bcd");
    user_string s1(p1.string<user_string>());
    CHECK(s1 == usr);
  }

# endif

}  // unnamed namespace

//--------------------------------------------------------------------------------------//
//                                                                                //
//                                     main                                             //
//                                                                                //
//--------------------------------------------------------------------------------------//

int cpp_main(int, char*[])
{
// document state of critical macros
#ifdef BOOST_POSIX_API
  cout << "BOOST_POSIX_API" << endl;
#endif
#ifdef BOOST_WINDOWS_API
  cout << "BOOST_WINDOWS_API" << endl;
#endif

  l.push_back('s');
  l.push_back('t');
  l.push_back('r');
  l.push_back('i');
  l.push_back('n');
  l.push_back('g');

  wl.push_back(L'w');
  wl.push_back(L's');
  wl.push_back(L't');
  wl.push_back(L'r');
  wl.push_back(L'i');
  wl.push_back(L'n');
  wl.push_back(L'g');

  v.push_back('f');
  v.push_back('u');
  v.push_back('z');

  wv.push_back(L'w');
  wv.push_back(L'f');
  wv.push_back(L'u');
  wv.push_back(L'z');

  test_overloads();
  test_constructors();
  test_assignments();
  test_appends();
  test_modifiers();
  test_observers();
  test_relationals();
  test_inserter_and_extractor();
  test_other_non_members();
  test_iterators();
  test_decompositions();
  test_queries();
  test_imbue_locale();
  test_codecvt_argument();
  test_error_handling();

# if 0

  test_user_supplied_type();

#endif

  std::string foo("\\abc");
  const char* bar = "/abc";

  if (foo == bar)
    cout << "unintended consequence\n";

  return ::boost::report_errors();
}

ext: cpp

max_issues_repo_name: wujf/mongo

max_forks_repo_name: wujf/mongo


text:
//
//  common.cpp
//  kcalg
//
//  Created by knightc on 2019/7/12.
//  Copyright © 2019 knightc. All rights reserved.
//

#include <stdio.h>

#include "opentsb/math.h"
#include <NTL/GF2X.h>
#include <NTL/ZZX.h>

using namespace NTL;
using namespace std;

 void lcm(ZZ& k, const ZZ& x, const ZZ& y) {
    ZZ gcd;
    mul(k, x, y);
    GCD(gcd, x, y);
    k /= gcd;
}

//一次性运算求 向量的 lcm/gcd
vec_ZZ lcm_gcd_vec(const vec_ZZ& v,int typemode){

    vec_ZZ vec_out;
    long m,n,j,i;
    ZZ temp;
    i=0;
    j=0;

     n= v.length();
    m= ceil(n/2.0);//向上取整，必须是非整数，即 2---》2.0
      vec_out.SetLength(m);
    switch (typemode) {
        case 1:
            for (i=0; i < n-1; i+=2) {

                lcm(temp,v[i],v[i+1]);
                // cout << temp<< endl;
                vec_out[j] = temp;
                //cout << vec_out << endl;
                j++;
                // cout << j << endl;
            }
            // cout << i << endl;
            if (n % 2 == 1 ) {
                lcm( vec_out[j],v[i],ZZ(1));
            }
            break;
         case 2:
            for (i=0; i < n-1; i+=2) {
                GCD(temp,v[i],v[i+1]);
                // cout << temp<< endl;
                vec_out[j] = temp;
                //cout << vec_out << endl;
                j++;
                // cout << j << endl;
            }
            // cout << i << endl;
            if (n % 2 == 1 ) {
                GCD( vec_out[j],v[i],v[i-1]);
            }
            break;
    }
    return vec_out;
}

//求 n 个数的最大公约数/最小公倍数
vec_ZZ lcm_gcd_vec(const vec_ZZ& v,int typemode,long endleng){

    vec_ZZ vec_out;

    vec_out= lcm_gcd_vec(v, typemode);
    endleng=vec_out.length();

    while (endleng != 1) {
       vec_out= lcm_gcd_vec(vec_out, typemode);
         endleng=vec_out.length();
    }

    return vec_out;
}

//array can use "for" to assignment，but vector can't。if must，can use vector.push_back
void array_to_vec(const ZZ arr[],vec_ZZ &v,long len) {
   // long n= v.length();

    v.SetLength(len);
    for (int i=0; i<=len-1; i++) {
        v[i]=arr[i];
    }
    //cout<<v<<endl;
}

void array_to_vec(const int arr[],vec_ZZ &v,long len) {
   // long n= v.length();

    for (int i=0; i<=len-1; i++) {
        v[i]=to_ZZ(arr[i]);

    }
    // cout<<v<<endl;
}

void array2_to_mat(const vector< vector<ZZ> > arr,mat_ZZ &v){
    long m= v.NumRows();
    long n= v.NumCols();

    for (int i=0;i<=m-1;i++){
        for (int j=0; j<=n-1; j++) {
            v[i][j]=arr[i][j];
        }
    }

}

void array2_to_mat(const vector< vector<int> > arr,mat_ZZ &v){
    long m= v.NumRows();
    long n= v.NumCols();

    for (int i=0;i<=m-1;i++){
        for (int j=0; j<=n-1; j++) {
            v[i][j]=to_ZZ(arr[i][j]);
        }
    }

}

void array2_to_mat(const vector< vector<int> > arr,mat_GF2 &v){
    long m= v.NumRows();
    long n= v.NumCols();

    for (int i=0;i<=m-1;i++){
        for (int j=0; j<=n-1; j++) {
            v[i][j]=to_GF2(arr[i][j]);
        }
    }

}

void array2_to_mat(const vector< vector<ZZ> > arr,mat_GF2 &v){
    long m= v.NumRows();
    long n= v.NumCols();

    for (int i=0;i<=m-1;i++){
        for (int j=0; j<=n-1; j++) {
            v[i][j]=to_GF2(arr[i][j]);
        }
    }

}

void array2_to_mat(const vector< vector<GF2> > arr,mat_GF2 &v){
    long m= v.NumRows();
    long n= v.NumCols();

    for (int i=0;i<=m-1;i++){
        for (int j=0; j<=n-1; j++) {
            v[i][j]=arr[i][j];
        }
    }

}

void array2_to_mat(const vector< vector<int> > arr,mat_GF2E &v){

    long m= v.NumRows();
    long n= v.NumCols();

//    const GF2X P(INIT_MONO,8);
//    GF2E::init(P);
    GF2X P;
    SetCoeff(P, 8, 1);
    SetCoeff(P, 4, 1);
    SetCoeff(P, 3, 1);
    SetCoeff(P, 1, 1);
    SetCoeff(P, 0, 1);
    GF2E::init(P);

    for (int i=0;i<=m-1;i++){
        for (int j=0; j<=n-1; j++) {
            v[i][j]=to_GF2E(arr[i][j]);
        }
    }

}

void array2_to_mat(const vector< vector<int> > arr,mat_ZZ_p &v){

    v.SetDims(arr.size(),arr[0].size());

    long m= v.NumRows();
    long n= v.NumCols();

    ZZ_p::init(ZZ(256));

    for (int i=0;i<=m-1;i++){
        for (int j=0; j<=n-1; j++) {
            v[i][j]=to_ZZ_p(long(arr[i][j]));
        }
    }

}

//void inv_array2_to_mat(const mat_GF2E &v, vector< vector<int> > &arr) //gf2e --> int  ?????

//to_ZZX(vec);可以把一个一维数组/向量 转为多项式（系数更换）
void kc_lagrange(vec_vec_ZZ_p &pointMat,vec_zz_p &coeffVec) {

}


text:
//!
//! Contains the implementation of some statistical diagnostic tests for MCMC.
//!
//! \file infer/diagnostics.hpp
//! \author Darren Shen
//! \date 2014
//! \license Affero General Public License version 3 or later
//! \copyright (c) 2014, NICTA
//!

#pragma once

#include <Eigen/Dense>

namespace stateline
{
  namespace mcmc
  {
    //! Convergence test using estimated potential scale reduction (EPSR).
    //! It is a convergence metric that takes into account the variance of the
    //! means between chains and the variance of the samples within each chain.
    //!
    class EpsrConvergenceCriteria
    {
      public:
        //! Initialise the convergence criteria.
        //!
        //! \param numChains The number of chains to be tested for convergence.
        //! \param numDims The number of dimensions in each state.
        //!
        EpsrConvergenceCriteria(int numChains, int numDims) :
          M_(Eigen::ArrayXXd::Zero(numDims, numChains)),
          S_(Eigen::ArrayXXd::Zero(numDims, numChains)),
          numSamples_(Eigen::ArrayXi::Zero(numChains))
        {
        }

        //! Update the convergence statistics for a new sample in a particular chain.
        //!
        //! \param id The chain which has the new sample.
        //! \param sample The new sample to update the convergence statistics with.
        //!
        void update(uint id, const Eigen::VectorXd &sample)
        {
          // See http://www.johndcook.com/standard_deviation.html
          int n = numSamples_(id) + 1;

          Eigen::ArrayXd x = sample.array();

          // Update the running mean and variance
          Eigen::ArrayXd newM = M_.col(id) + (x - M_.col(id)) / n;
          S_.col(id) = S_.col(id) + (x - M_.col(id)) * (x - newM);
          M_.col(id) = newM;

          numSamples_(id) = n;
        }

        //! Compute the estimated potential scale factor. A low value indicates
        //! that the chains are converging.
        //!
        //! \return A vector containing the scale factors for each dimension.
        //!
        Eigen::ArrayXd rHat() const
        {
          // Number of samples (use the length of the shortest chain)
          int n = numSamples_.minCoeff();

          // Number of chains
          int m = numSamples_.rows();

          // Find the overall mean of the chains
          Eigen::ArrayXXd overallMean = M_.rowwise().mean().replicate(1, M_.cols());

          // Calculate the between chain variance
          Eigen::ArrayXd b = (n / (m - 1.0)) * (M_ - overallMean).matrix().rowwise().squaredNorm().array();

          // Calculate the within chain variance
          Eigen::ArrayXd w = ((1.0 / m) * S_ / (n - 1.0)).rowwise().sum();

          // Compute the weighted average of the between chain variance and within chain variance
          Eigen::ArrayXd vHat = ((n - 1.0) / n) * w + (1.0 / n) * b;

          // Compute the potential scale reduction
          return (vHat / (w + 1e-30)).sqrt();
        }

        //! Check if all the chains have converged. The chains have converged if the
        //! potential scale reduction factor is below 1.1 for all dimensions.
        //!
        //! \return Whether all the chains have converged.
        //!
        bool hasConverged() const
        {
          return (rHat() < 1.1).all();
        }

      private:
        Eigen::ArrayXXd M_;
        Eigen::ArrayXXd S_;
        Eigen::ArrayXi numSamples_;
    };
  }
}


text:
//---------------------------------------------------------------------------//
// Copyright (c) 2018-2020 Mikhail Komarov <nemo@nil.foundation>
// Copyright (c) 2021 Ilias Khairullin <ilias@nil.foundation>
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//---------------------------------------------------------------------------//

#ifndef CRYPTO3_MAC_VALUE_HPP
#define CRYPTO3_MAC_VALUE_HPP

#include <type_traits>
#include <iterator>

#include <boost/assert.hpp>
#include <boost/concept_check.hpp>

#include <boost/range/concepts.hpp>

#include <boost/mpl/front.hpp>
#include <boost/mpl/apply.hpp>

#include <nil/crypto3/mac/accumulators/mac.hpp>

namespace nil {
    namespace crypto3 {
        namespace mac {
            namespace detail {
                template<typename MacAccumulator>
                struct ref_mac_impl {
                    typedef MacAccumulator accumulator_set_type;
                    typedef
                        typename boost::mpl::front<typename accumulator_set_type::features_type>::type accumulator_type;

                    ref_mac_impl(accumulator_set_type &&acc) : accumulator_set(acc) {
                    }

                    accumulator_set_type &accumulator_set;
                };

                template<typename MacAccumulator>
                struct value_mac_impl {
                    typedef MacAccumulator accumulator_set_type;
                    typedef
                        typename boost::mpl::front<typename accumulator_set_type::features_type>::type accumulator_type;

                    value_mac_impl(accumulator_set_type &&acc) :
                        accumulator_set(std::forward<accumulator_set_type>(acc)) {
                    }

                    mutable accumulator_set_type accumulator_set;
                };

                template<typename MacStateImpl>
                struct range_mac_impl : public MacStateImpl {
                    typedef MacStateImpl mac_state_impl_type;

                    typedef typename mac_state_impl_type::accumulator_type accumulator_type;
                    typedef typename mac_state_impl_type::accumulator_set_type accumulator_set_type;

                    typedef typename boost::mpl::apply<accumulator_set_type, accumulator_type>::type::result_type
                        result_type;

                    template<typename SinglePassRange>
                    range_mac_impl(const SinglePassRange &range, accumulator_set_type &&ise) :
                        MacStateImpl(std::forward<accumulator_set_type>(ise)) {
                        BOOST_RANGE_CONCEPT_ASSERT((boost::SinglePassRangeConcept<const SinglePassRange>));

                        this->accumulator_set(range);
                    }

                    template<typename InputIterator>
                    range_mac_impl(InputIterator first, InputIterator last, accumulator_set_type &&ise) :
                        MacStateImpl(std::forward<accumulator_set_type>(ise)) {
                        BOOST_CONCEPT_ASSERT((boost::InputIteratorConcept<InputIterator>));

                        this->accumulator_set(first, ::nil::crypto3::accumulators::iterator_last = last);
                    }

                    template<typename OutputRange>
                    operator OutputRange() const {
                        result_type result =
                            boost::accumulators::extract_result<accumulator_type>(this->accumulator_set);
                        return OutputRange(result.cbegin(), result.cend());
                    }

                    operator result_type() const {
                        return boost::accumulators::extract_result<accumulator_type>(this->accumulator_set);
                    }

                    operator accumulator_set_type &() const {
                        return this->accumulator_set;
                    }

#ifdef CRYPTO3_ASCII_STRING_CODEC_OUTPUT
                    template<typename Char, typename CharTraits, typename Alloc>
                    operator std::basic_string<Char, CharTraits, Alloc>() const {
                        return std::to_string(
                            boost::accumulators::extract_result<accumulator_type>(this->accumulator_set));
                    }
#endif
                };

                template<typename MacStateImpl, typename OutputIterator>
                struct itr_mac_impl : public MacStateImpl {
                private:
                    mutable OutputIterator out;

                public:
                    typedef MacStateImpl mac_state_impl_type;

                    typedef typename mac_state_impl_type::accumulator_type accumulator_type;
                    typedef typename mac_state_impl_type::accumulator_set_type accumulator_set_type;

                    typedef typename boost::mpl::apply<accumulator_set_type, accumulator_type>::type::result_type
                        result_type;

                    template<typename SinglePassRange>
                    itr_mac_impl(const SinglePassRange &range, OutputIterator out, accumulator_set_type &&ise) :
                        MacStateImpl(std::forward<accumulator_set_type>(ise)), out(std::move(out)) {
                        BOOST_CONCEPT_ASSERT((boost::SinglePassRangeConcept<const SinglePassRange>));
                        BOOST_CONCEPT_ASSERT((boost::OutputIteratorConcept<OutputIterator, result_type>));

                        this->accumulator_set(range);
                    }

                    template<typename InputIterator>
                    itr_mac_impl(InputIterator first, InputIterator last, OutputIterator out,
                                 accumulator_set_type &&ise) :
                        MacStateImpl(std::forward<accumulator_set_type>(ise)),
                        out(std::move(out)) {
                        BOOST_CONCEPT_ASSERT((boost::InputIteratorConcept<InputIterator>));
                        BOOST_CONCEPT_ASSERT((boost::OutputIteratorConcept<OutputIterator, result_type>));

                        this->accumulator_set(first, ::nil::crypto3::accumulators::iterator_last = last);
                    }

                    operator OutputIterator() const {
                        *out++ = boost::accumulators::extract_result<accumulator_type>(this->accumulator_set);
                        return out;
                    }
                };
            }    // namespace detail
        }        // namespace mac
    }            // namespace crypto3
}    // namespace nil

#endif    // CRYPTO3_CODEC_POSTPROCESSOR_HPP

max_stars_repo_name: NilFoundation/mac

max_issues_repo_name: NilFoundation/mac

max_forks_repo_name: NilFoundation/mac


text:
#pragma once

#include <map>
#include <vector>

#include <Eigen/Core>
#include <nlohmann/json.hpp>

namespace polyfem
{

	class ImplicitTimeIntegrator
	{
	public:
		ImplicitTimeIntegrator() {}
		virtual ~ImplicitTimeIntegrator() = default;

		virtual void set_parameters(const nlohmann::json &params) {}

		virtual void init(const Eigen::VectorXd &x_prev, const Eigen::VectorXd &v_prev, const Eigen::VectorXd &a_prev, double dt);

		virtual void update_quantities(const Eigen::VectorXd &x) = 0;

		virtual Eigen::VectorXd x_tilde() const = 0;

		virtual double acceleration_scaling() const = 0;

		const double &dt() const { return _dt; }

		virtual void save_raw(const std::string &x_path, const std::string &v_path, const std::string &a_path) const;

		static std::shared_ptr<ImplicitTimeIntegrator> construct_time_integrator(const std::string &name);
		static const std::vector<std::string> &get_time_integrator_names();

	protected:
		double _dt;
		Eigen::VectorXd x_prev, v_prev, a_prev;
	};

} // namespace polyfem

max_stars_repo_name: danielepanozzo/polyfem

max_issues_repo_name: danielepanozzo/polyfem

max_forks_repo_name: danielepanozzo/polyfem


text:
/* ----------------------------------------------------------------------------

 * GTSAM Copyright 2010, Georgia Tech Research Corporation,
 * Atlanta, Georgia 30332-0415
 * All Rights Reserved
 * Authors: Frank Dellaert, et al. (see THANKS for the full author list)

 * See LICENSE for the license information

 * -------------------------------------------------------------------------- */

/**
 * @file    smallExample.cpp
 * @brief   Create small example with two poses and one landmark
 * @brief   smallExample
 * @author  Carlos Nieto
 * @author  Frank dellaert
 */

#include <gtsam/nonlinear/Symbol.h>
#include <gtsam/nonlinear/Ordering.h>
#include <gtsam/nonlinear/NonlinearFactorGraph.h>
#include <gtsam/nonlinear/NonlinearFactor.h>
#include <gtsam/inference/FactorGraph.h>
#include <gtsam/base/Matrix.h>

#include <tests/smallExample.h>

#include <boost/optional.hpp>
#include <boost/shared_ptr.hpp>

#include <iostream>
#include <string>

using namespace std;

namespace gtsam {
namespace example {

	using namespace gtsam::noiseModel;

	typedef boost::shared_ptr<NonlinearFactor> shared;

	static SharedDiagonal sigma1_0 = noiseModel::Isotropic::Sigma(2,1.0);
	static SharedDiagonal sigma0_1 = noiseModel::Isotropic::Sigma(2,0.1);
	static SharedDiagonal sigma0_2 = noiseModel::Isotropic::Sigma(2,0.2);
	static SharedDiagonal constraintModel = noiseModel::Constrained::All(2);

	static const Index _l1_=0, _x1_=1, _x2_=2;
	static const Index _x_=0, _y_=1, _z_=2;

	// Convenience for named keys
	using symbol_shorthand::X;
	using symbol_shorthand::L;

	/* ************************************************************************* */
	boost::shared_ptr<const Graph> sharedNonlinearFactorGraph() {
		// Create
		boost::shared_ptr<Graph> nlfg(
				new Graph);

		// prior on x1
		Point2 mu;
		shared f1(new simulated2D::Prior(mu, sigma0_1, X(1)));
		nlfg->push_back(f1);

		// odometry between x1 and x2
		Point2 z2(1.5, 0);
		shared f2(new simulated2D::Odometry(z2, sigma0_1, X(1), X(2)));
		nlfg->push_back(f2);

		// measurement between x1 and l1
		Point2 z3(0, -1);
		shared f3(new simulated2D::Measurement(z3, sigma0_2, X(1), L(1)));
		nlfg->push_back(f3);

		// measurement between x2 and l1
		Point2 z4(-1.5, -1.);
		shared f4(new simulated2D::Measurement(z4, sigma0_2, X(2), L(1)));
		nlfg->push_back(f4);

		return nlfg;
	}

	/* ************************************************************************* */
	Graph createNonlinearFactorGraph() {
		return *sharedNonlinearFactorGraph();
	}

	/* ************************************************************************* */
	Values createValues() {
		Values c;
		c.insert(X(1), Point2(0.0, 0.0));
		c.insert(X(2), Point2(1.5, 0.0));
		c.insert(L(1), Point2(0.0, -1.0));
		return c;
	}

	/* ************************************************************************* */
	VectorValues createVectorValues() {
		VectorValues c(vector<size_t>(3, 2));
		c[_l1_] = Vector_(2, 0.0, -1.0);
		c[_x1_] = Vector_(2, 0.0, 0.0);
		c[_x2_] = Vector_(2, 1.5, 0.0);
		return c;
	}

	/* ************************************************************************* */
	boost::shared_ptr<const Values> sharedNoisyValues() {
		boost::shared_ptr<Values> c(new Values);
		c->insert(X(1), Point2(0.1, 0.1));
		c->insert(X(2), Point2(1.4, 0.2));
		c->insert(L(1), Point2(0.1, -1.1));
		return c;
	}

	/* ************************************************************************* */
	Values createNoisyValues() {
		return *sharedNoisyValues();
	}

	/* ************************************************************************* */
	VectorValues createCorrectDelta(const Ordering& ordering) {
		VectorValues c(vector<size_t>(3,2));
		c[ordering[L(1)]] = Vector_(2, -0.1, 0.1);
		c[ordering[X(1)]] = Vector_(2, -0.1, -0.1);
		c[ordering[X(2)]] = Vector_(2, 0.1, -0.2);
		return c;
	}

	/* ************************************************************************* */
	VectorValues createZeroDelta(const Ordering& ordering) {
		VectorValues c(vector<size_t>(3,2));
		c[ordering[L(1)]] = zero(2);
		c[ordering[X(1)]] = zero(2);
		c[ordering[X(2)]] = zero(2);
		return c;
	}

	/* ************************************************************************* */
	GaussianFactorGraph createGaussianFactorGraph(const Ordering& ordering) {
		// Create empty graph
	  GaussianFactorGraph fg;

		SharedDiagonal unit2 = noiseModel::Unit::Create(2);

		// linearized prior on x1: c[_x1_]+x1=0 i.e. x1=-c[_x1_]
		fg.push_back(boost::make_shared<JacobianFactor>(ordering[X(1)], 10*eye(2), -1.0*ones(2), unit2));

		// odometry between x1 and x2: x2-x1=[0.2;-0.1]
		fg.push_back(boost::make_shared<JacobianFactor>(ordering[X(1)], -10*eye(2),ordering[X(2)], 10*eye(2), Vector_(2, 2.0, -1.0), unit2));

    // measurement between x1 and l1: l1-x1=[0.0;0.2]
		fg.push_back(boost::make_shared<JacobianFactor>(ordering[X(1)], -5*eye(2), ordering[L(1)], 5*eye(2), Vector_(2, 0.0, 1.0), unit2));

		// measurement between x2 and l1: l1-x2=[-0.2;0.3]
		fg.push_back(boost::make_shared<JacobianFactor>(ordering[X(2)], -5*eye(2), ordering[L(1)], 5*eye(2), Vector_(2, -1.0, 1.5), unit2));

		return fg;
	}

	/* ************************************************************************* */
	/** create small Chordal Bayes Net x <- y
	 * x y d
	 * 1 1 9
	 *   1 5
	 */
	GaussianBayesNet createSmallGaussianBayesNet() {
		Matrix R11 = Matrix_(1, 1, 1.0), S12 = Matrix_(1, 1, 1.0);
		Matrix R22 = Matrix_(1, 1, 1.0);
		Vector d1(1), d2(1);
		d1(0) = 9;
		d2(0) = 5;
		Vector tau(1);
		tau(0) = 1.0;

		// define nodes and specify in reverse topological sort (i.e. parents last)
		GaussianConditional::shared_ptr Px_y(new GaussianConditional(_x_, d1, R11, _y_, S12, tau));
		GaussianConditional::shared_ptr Py(new GaussianConditional(_y_, d2, R22, tau));
		GaussianBayesNet cbn;
		cbn.push_back(Px_y);
		cbn.push_back(Py);

		return cbn;
	}

	/* ************************************************************************* */
	// Some nonlinear functions to optimize
	/* ************************************************************************* */
	namespace smallOptimize {

		Point2 h(const Point2& v) {
			return Point2(cos(v.x()), sin(v.y()));
		}

		Matrix H(const Point2& v) {
			return Matrix_(2, 2,
					-sin(v.x()), 0.0,
					 0.0, cos(v.y()));
		}

		struct UnaryFactor: public gtsam::NoiseModelFactor1<Point2> {

			Point2 z_;

			UnaryFactor(const Point2& z, const SharedNoiseModel& model, Key key) :
				gtsam::NoiseModelFactor1<Point2>(model, key), z_(z) {
			}

			Vector evaluateError(const Point2& x, boost::optional<Matrix&> A = boost::none) const {
				if (A) *A = H(x);
				return (h(x) - z_).vector();
			}

		};

	}

	/* ************************************************************************* */
	boost::shared_ptr<const Graph> sharedReallyNonlinearFactorGraph() {
		boost::shared_ptr<Graph> fg(new Graph);
		Vector z = Vector_(2, 1.0, 0.0);
		double sigma = 0.1;
		boost::shared_ptr<smallOptimize::UnaryFactor> factor(
				new smallOptimize::UnaryFactor(z, noiseModel::Isotropic::Sigma(2,sigma), X(1)));
		fg->push_back(factor);
		return fg;
	}

	Graph createReallyNonlinearFactorGraph() {
		return *sharedReallyNonlinearFactorGraph();
	}

	/* ************************************************************************* */
	pair<Graph, Values> createNonlinearSmoother(int T) {

		// Create
		Graph nlfg;
		Values poses;

		// prior on x1
		Point2 x1(1.0, 0.0);
		shared prior(new simulated2D::Prior(x1, sigma1_0, X(1)));
		nlfg.push_back(prior);
		poses.insert(X(1), x1);

		for (int t = 2; t <= T; t++) {
			// odometry between x_t and x_{t-1}
			Point2 odo(1.0, 0.0);
			shared odometry(new simulated2D::Odometry(odo, sigma1_0, X(t - 1), X(t)));
			nlfg.push_back(odometry);

			// measurement on x_t is like perfect GPS
			Point2 xt(t, 0);
			shared measurement(new simulated2D::Prior(xt, sigma1_0, X(t)));
			nlfg.push_back(measurement);

			// initial estimate
			poses.insert(X(t), xt);
		}

		return make_pair(nlfg, poses);
	}

	/* ************************************************************************* */
	pair<FactorGraph<GaussianFactor>, Ordering> createSmoother(int T, boost::optional<Ordering> ordering) {
		Graph nlfg;
		Values poses;
		boost::tie(nlfg, poses) = createNonlinearSmoother(T);

		if(!ordering) ordering = *poses.orderingArbitrary();
		return make_pair(*nlfg.linearize(poses, *ordering), *ordering);
	}

	/* ************************************************************************* */
	GaussianFactorGraph createSimpleConstraintGraph() {
		// create unary factor
		// prior on _x_, mean = [1,-1], sigma=0.1
		Matrix Ax = eye(2);
		Vector b1(2);
		b1(0) = 1.0;
		b1(1) = -1.0;
		JacobianFactor::shared_ptr f1(new JacobianFactor(_x_, Ax, b1, sigma0_1));

		// create binary constraint factor
		// between _x_ and _y_, that is going to be the only factor on _y_
		// |1 0||x_1| + |-1  0||y_1| = |0|
		// |0 1||x_2|   | 0 -1||y_2|   |0|
		Matrix Ax1 = eye(2);
		Matrix Ay1 = eye(2) * -1;
		Vector b2 = Vector_(2, 0.0, 0.0);
		JacobianFactor::shared_ptr f2(new JacobianFactor(_x_, Ax1, _y_, Ay1, b2,
				constraintModel));

		// construct the graph
		GaussianFactorGraph fg;
		fg.push_back(f1);
		fg.push_back(f2);

		return fg;
	}

	/* ************************************************************************* */
	VectorValues createSimpleConstraintValues() {
		VectorValues config(vector<size_t>(2,2));
		Vector v = Vector_(2, 1.0, -1.0);
		config[_x_] = v;
		config[_y_] = v;
		return config;
	}

	/* ************************************************************************* */
	GaussianFactorGraph createSingleConstraintGraph() {
		// create unary factor
		// prior on _x_, mean = [1,-1], sigma=0.1
		Matrix Ax = eye(2);
		Vector b1(2);
		b1(0) = 1.0;
		b1(1) = -1.0;
		//GaussianFactor::shared_ptr f1(new JacobianFactor(_x_, sigma0_1->Whiten(Ax), sigma0_1->whiten(b1), sigma0_1));
		JacobianFactor::shared_ptr f1(new JacobianFactor(_x_, Ax, b1, sigma0_1));

		// create binary constraint factor
		// between _x_ and _y_, that is going to be the only factor on _y_
		// |1 2||x_1| + |10 0||y_1| = |1|
		// |2 1||x_2|   |0 10||y_2|   |2|
		Matrix Ax1(2, 2);
		Ax1(0, 0) = 1.0;
		Ax1(0, 1) = 2.0;
		Ax1(1, 0) = 2.0;
		Ax1(1, 1) = 1.0;
		Matrix Ay1 = eye(2) * 10;
		Vector b2 = Vector_(2, 1.0, 2.0);
		JacobianFactor::shared_ptr f2(new JacobianFactor(_x_, Ax1, _y_, Ay1, b2,
				constraintModel));

		// construct the graph
		GaussianFactorGraph fg;
		fg.push_back(f1);
		fg.push_back(f2);

		return fg;
	}

	/* ************************************************************************* */
	VectorValues createSingleConstraintValues() {
		VectorValues config(vector<size_t>(2,2));
		config[_x_] = Vector_(2, 1.0, -1.0);
		config[_y_] = Vector_(2, 0.2, 0.1);
		return config;
	}

	/* ************************************************************************* */
	GaussianFactorGraph createMultiConstraintGraph() {
		// unary factor 1
		Matrix A = eye(2);
		Vector b = Vector_(2, -2.0, 2.0);
		JacobianFactor::shared_ptr lf1(new JacobianFactor(_x_, A, b, sigma0_1));

		// constraint 1
		Matrix A11(2, 2);
		A11(0, 0) = 1.0;
		A11(0, 1) = 2.0;
		A11(1, 0) = 2.0;
		A11(1, 1) = 1.0;

		Matrix A12(2, 2);
		A12(0, 0) = 10.0;
		A12(0, 1) = 0.0;
		A12(1, 0) = 0.0;
		A12(1, 1) = 10.0;

		Vector b1(2);
		b1(0) = 1.0;
		b1(1) = 2.0;
		JacobianFactor::shared_ptr lc1(new JacobianFactor(_x_, A11, _y_, A12, b1,
				constraintModel));

		// constraint 2
		Matrix A21(2, 2);
		A21(0, 0) = 3.0;
		A21(0, 1) = 4.0;
		A21(1, 0) = -1.0;
		A21(1, 1) = -2.0;

		Matrix A22(2, 2);
		A22(0, 0) = 1.0;
		A22(0, 1) = 1.0;
		A22(1, 0) = 1.0;
		A22(1, 1) = 2.0;

		Vector b2(2);
		b2(0) = 3.0;
		b2(1) = 4.0;
		JacobianFactor::shared_ptr lc2(new JacobianFactor(_x_, A21, _z_, A22, b2,
				constraintModel));

		// construct the graph
		GaussianFactorGraph fg;
		fg.push_back(lf1);
		fg.push_back(lc1);
		fg.push_back(lc2);

		return fg;
	}

	/* ************************************************************************* */
	VectorValues createMultiConstraintValues() {
		VectorValues config(vector<size_t>(3,2));
		config[_x_] = Vector_(2, -2.0, 2.0);
		config[_y_] = Vector_(2, -0.1, 0.4);
		config[_z_] = Vector_(2, -4.0, 5.0);
		return config;
	}

	/* ************************************************************************* */
	// Create key for simulated planar graph
	Symbol key(int x, int y) {
		return X(1000*x+y);
	}

	/* ************************************************************************* */
	boost::tuple<GaussianFactorGraph, VectorValues> planarGraph(size_t N) {

		// create empty graph
		NonlinearFactorGraph nlfg;

		// Create almost hard constraint on x11, sigma=0 will work for PCG not for normal
		shared constraint(new simulated2D::Prior(Point2(1.0, 1.0), Isotropic::Sigma(2,1e-3), key(1,1)));
		nlfg.push_back(constraint);

		// Create horizontal constraints, 1...N*(N-1)
		Point2 z1(1.0, 0.0); // move right
		for (size_t x = 1; x < N; x++)
			for (size_t y = 1; y <= N; y++) {
				shared f(new simulated2D::Odometry(z1, Isotropic::Sigma(2,0.01), key(x, y), key(x + 1, y)));
				nlfg.push_back(f);
			}

		// Create vertical constraints, N*(N-1)+1..2*N*(N-1)
		Point2 z2(0.0, 1.0); // move up
		for (size_t x = 1; x <= N; x++)
			for (size_t y = 1; y < N; y++) {
				shared f(new simulated2D::Odometry(z2, Isotropic::Sigma(2,0.01), key(x, y), key(x, y + 1)));
				nlfg.push_back(f);
			}

		// Create linearization and ground xtrue config
		Values zeros;
    for (size_t x = 1; x <= N; x++)
      for (size_t y = 1; y <= N; y++)
        zeros.insert(key(x, y), Point2());
		Ordering ordering(planarOrdering(N));
		VectorValues xtrue(zeros.dims(ordering));
		for (size_t x = 1; x <= N; x++)
			for (size_t y = 1; y <= N; y++)
				xtrue[ordering[key(x, y)]] = Point2(x,y).vector();

		// linearize around zero
		boost::shared_ptr<GaussianFactorGraph> gfg = nlfg.linearize(zeros, ordering);
		return boost::make_tuple(*gfg, xtrue);
	}

	/* ************************************************************************* */
	Ordering planarOrdering(size_t N) {
		Ordering ordering;
		for (size_t y = N; y >= 1; y--)
			for (size_t x = N; x >= 1; x--)
				ordering.push_back(key(x, y));
		return ordering;
	}

	/* ************************************************************************* */
	pair<GaussianFactorGraph, GaussianFactorGraph > splitOffPlanarTree(size_t N,
			const GaussianFactorGraph& original) {
		GaussianFactorGraph T, C;

		// Add the x11 constraint to the tree
		T.push_back(original[0]);

		// Add all horizontal constraints to the tree
		size_t i = 1;
		for (size_t x = 1; x < N; x++)
			for (size_t y = 1; y <= N; y++, i++)
				T.push_back(original[i]);

		// Add first vertical column of constraints to T, others to C
		for (size_t x = 1; x <= N; x++)
			for (size_t y = 1; y < N; y++, i++)
				if (x == 1)
					T.push_back(original[i]);
				else
					C.push_back(original[i]);

		return make_pair(T, C);
	}

/* ************************************************************************* */

} // example
} // namespace gtsam


text:
//////////////////////////////////////////////////////////////////////////////
//  Boost.Assign v2                                                         //
//                                                                          //
//  Copyright (C) 2003-2004 Thorsten Ottosen                                //
//  Copyright (C) 2011 Erwann Rogard                                        //
//  Use, modification and distribution are subject to the                   //
//  Boost Software License, Version 1.0. (See accompanying file             //
//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)        //
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_ASSIGN_V2_OPTION_DATA_ER_2011_HPP
#define BOOST_ASSIGN_V2_OPTION_DATA_ER_2011_HPP
#include <boost/assign/v2/support/functor/pair.hpp>
#include <boost/assign/v2/support/functor/value.hpp>
#include <boost/assign/v2/support/keyword.hpp>
#include <boost/assign/v2/support/pp/ignore.hpp>
#include <boost/assign/v2/support/traits/container.hpp>
#include <boost/assign/v2/interpreter/fwd.hpp>
#include <boost/assign/v2/interpreter/replace.hpp>
#include <boost/assign/v2/option/list.hpp>
#include <boost/mpl/apply.hpp>

namespace boost{
namespace assign{
namespace v2{
//[syntax_option_data
namespace interpreter_aux{

    template<
        typename C      // Value- or pointer-container
        , typename F    // Functor or keyword
    >
    struct data_generator/*<-*/
    {
        typedef F type;
    }/*->*/;

    template<
        typename C // Multi-array
    >
    struct data_generator<C, kwd_element_>/*<-*/
    {
        typedef typename container_aux::element<C>::type element_;
        typedef functor_aux::value<element_> type;
    }/*->*/;

    template<typename C>
    struct data_generator<C, kwd_key_>/*<-*/
    {
        typedef typename container_aux::key<C>::type key_;
        typedef functor_aux::value<key_> type;
    }/*->*/;

    template<typename C>
    struct data_generator<C, kwd_map_>/*<-*/
    {
        typedef typename container_aux::key<C>::type key_;
        typedef typename container_aux::mapped<C>::type mapped_;
        typedef typename container_aux::value<C>::type value_;
        typedef functor_aux::pair<value_, key_, mapped_> type;
    }/*->*/;

    template<typename C>
    struct data_generator<C, kwd_use_default_>/*<-*/
        : deduce_data_generator<C>
    {}/*->*/;

    template<typename C>
    struct data_generator<C, kwd_value_>/*<-*/
    {
        typedef functor_aux::value<
            typename container_aux::value<C>::type
        > type;
    }/*->*/;

namespace result_of{

    template<typename D, typename C, typename F = kwd_use_default_>
    struct option_data/*<-*/
        : ::boost::mpl::apply1<
            interpreter_aux::replace_data_generator<D>,
            typename data_generator<C, F>::type
        >
    {}/*->*/;

}// result_of

    // F is either a functor or one of the keywords :
    //  element_, key_, map_, use_default_, value_
    template<typename F = kwd_ignore_>
    struct option_data/*<-*/
        : option_crtp<
            option_data<F>
        >
    {
        option_data(){}
        option_data(F f) : f_( f ){}

        template<typename C>
        F const& get()const{ return this->f_; }

        private:
        F f_;
    }/*->*/;

//<-
    template<typename Kwd>
    struct option_data_helper
        : option_crtp<
            option_data<Kwd>
        >
    {
        template<typename C>
        typename data_generator<C, Kwd>::type
        get()const
        {
            return typename data_generator<C, Kwd>::type();
        }
    };
}// interpreter_aux
#define BOOST_ASSIGN_V2_MACRO(Kwd, Alias)\
namespace interpreter_aux{\
    template<>\
    struct option_data<Kwd>\
        : option_data_helper<Kwd>\
    {\
        option_data(){}\
        option_data(kwd_ignore_){}\
    };\
}\
typedef interpreter_aux::option_data<Kwd> Alias;\
/**/
BOOST_ASSIGN_V2_MACRO(kwd_element_, element_)
BOOST_ASSIGN_V2_MACRO(kwd_key_, key_)
BOOST_ASSIGN_V2_MACRO(kwd_map_, map_)
BOOST_ASSIGN_V2_MACRO(kwd_use_default_, use_default_)
BOOST_ASSIGN_V2_MACRO(kwd_value_, value_)
#undef BOOST_ASSIGN_V2_MACRO
namespace interpreter_aux{
//->

    // Overrides data generator
    template<typename D, typename C, typename F, typename MTag
        , typename DTag, typename F1>
    typename result_of::option_data<D, C, F1>::type
    operator%(
        interpreter_crtp<D, C, F, MTag, DTag> const& lhs,
        option_data<F1> const& rhs
    )/*<-*/
    {
        typedef typename result_of::option_data<
            D, C, F1
        >::type result_;
        return result_(
            lhs.container(),
            rhs.template get<C>(),
            lhs.modifier
        );
    }BOOST_ASSIGN_V2_IGNORE(/*->*/;/*<-*/)/*->*/

    struct keyword_data
    {

        template<typename F>
        option_data<F> operator=(F const& f)const/*<-*/{
            return option_data<F>( f );
        }BOOST_ASSIGN_V2_IGNORE(/*->*/;/*<-*/)/*->*/

    };

}// interpreter_aux
namespace{
    const interpreter_aux::keyword_data _data/*<-*/ = {}/*->*/;
}
namespace result_of{

    using interpreter_aux::result_of::option_data;

}// result_of
//]
}// v2
}// assign
}// boost

#include <boost/preprocessor/cat.hpp>

#define BOOST_ASSIGN_V2_OPTION_DATA_GENERATE(NAME, FUN)\
namespace boost{\
namespace assign{\
namespace v2{\
namespace interpreter_aux{\
\
    template<typename T>\
    option_data< FUN > NAME()\
    {\
        return ( v2::_data = FUN() );\
    }\
\
}\
using interpreter_aux::NAME;\
}\
}\
}\
/**/

#include <boost/assign/v2/support/functor/value.hpp>
BOOST_ASSIGN_V2_OPTION_DATA_GENERATE(value, v2::functor_aux::value<T>)

#include <boost/typeof/typeof.hpp>
#include <boost/type_traits/add_const.hpp>
#define BOOST_ASSIGN_V2_OPTION_DATA_KEYWORD(NAME, EXPR)\
namespace boost{\
namespace assign{\
namespace v2{\
    typedef BOOST_TYPEOF( ( _data = EXPR ) ) BOOST_PP_CAT(type_of,NAME);\
namespace{\
\
    boost::add_const<BOOST_PP_CAT(type_of,NAME)>::type BOOST_PP_CAT(_,NAME) = ( _data = EXPR );\
}\
}\
}\
}\

#include <boost/lambda/lambda.hpp>
BOOST_ASSIGN_V2_OPTION_DATA_KEYWORD(identity, ::boost::lambda::_1)

#endif // BOOST_ASSIGN_V2_OPTION_DATA_ER_2011_HPP


text:
#include <assert.h>
#include <stdio.h>

#include <string>
#include <boost/shared_ptr.hpp>
#include <thrift/transport/TTransport.h>

#include "amqp.h"

#include "AmqpInterface.h"
#include "AmqpTransport.h"
#include "AmqpServerTransport.h"
#include "Debug.h"

using namespace waste;
using namespace apache::thrift::transport;
using namespace std;

const char* AmqpServerTransport::MODULE = "AmqpServerTransport";

// constructors and destructor
AmqpServerTransport::AmqpServerTransport(boost::shared_ptr<Amqp::Channel> channel,
                                         const string& exchangeName,
                                         const string& routingKey,
                                         const string& queueName) :
    fChannel(channel),
    fExchangeName(exchangeName),
    fRoutingKey(routingKey),
    fQueueName(queueName)
{
    assert(fChannel.get() != NULL);

    int result = fChannel->setupQueue(exchangeName, routingKey, queueName);
    result = result & fChannel->subscribe(queueName);

    // TODO : does something for exceptional cases
}

AmqpServerTransport::~AmqpServerTransport()
{
    // nothing is done
}

// public member functions
void
AmqpServerTransport::close()
{
    if (Debug::ON) {
        Debug::LOG(MODULE, __FILE__, __LINE__, "closing...");
    }
    // does nothing
}

// protected member functions
boost::shared_ptr<TTransport>
AmqpServerTransport::acceptImpl()
{
    message_string message;
    string routingKey;
    string replyTo;

    fChannel->waitForMessage(message, replyTo);

    AmqpTransport* amqpTransport = new AmqpTransport(fChannel, fExchangeName, routingKey, replyTo);

    // write the message to the memory buffer
    amqpTransport->write(message.data(), message.length());

    return ( boost::shared_ptr<TTransport>(amqpTransport) );
}

max_stars_repo_name: mille-printemps/waste

max_issues_repo_name: mille-printemps/waste

max_forks_repo_name: mille-printemps/waste


text:
//
// The MIT License(MIT)
//
// Copyright(c) 2014 Demonsaw LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

#include <boost/algorithm/string.hpp>
#include <boost/format.hpp>

#include "client_group_request_command.h"
#include "component/session_component.h"
#include "component/client/client_component.h"
#include "json/json_packet.h"
#include "message/request/group_request_message.h"
#include "message/response/group_response_message.h"
#include "security/base.h"
#include "utility/std.h"

namespace eja
{
	// Utility
	http_status client_group_request_command::execute()
	{
		// Request
		const auto request_packet = json_packet::create();
		const auto request_message = group_request_message::create(request_packet);

		// Session
		const auto session = get_session();
		if (!session)
			return http_code::bad_request;

		// Json
		const auto json = request_packet->str();
		const auto json_encrypted = session->encrypt(json);
		const auto json_encoded = base64::encode(json_encrypted);

		// Http
		http_request request(session->get_id());
		request.set_host(get_address());
		request.set_body(json_encoded);
		m_socket->write(request);

		http_response response;
		m_socket->read(response);

		const auto& status = response.get_status();
		if (status.is_ok())
		{
			// Body
			const auto& body = response.get_body();
			if (body.empty())
				return http_code::not_found;

			const auto body_decoded = base64::decode(body);
			const auto body_decypted = session->decrypt(body_decoded);

			// Response
			const auto response_packet = json_packet::create(body_decypted);
			const auto response_message = group_response_message::create(response_packet);
			const auto response_clients = response_message->get_clients();

			const auto temp_list = client_entity_vector_component::create();
			const auto client_vector = get_client_vector();
			if (!client_vector)
				return http_code::bad_request;

			for (const auto& value : *response_clients)
			{
				const auto response_value = json_value::create(value);
				const auto response_client = json_client::create(response_value);
				const auto client_id = response_client->get_id();

				// TODO: Optimize this!
				// TODO: Add client_entity_map_component
				auto entity = client_vector->find_if([client_id](const entity::ptr e)
				{
					const auto c = e->get<client_component>();
					return c && (c->get_id() == client_id);
				});

				const auto name = response_client->get_name();

				if (!entity)
				{
					const auto client = client_component::create(response_client->get_id());
					client->set_name(name);
					client->set_join_name(name);

					entity = entity::create();
					entity->add(client);
				}
				else
				{
					const auto client = entity->get<client_component>();
					if (client)
					{
						client->set_name(name);
						client->set_join_name(name);
					}
				}

				temp_list->add(entity);
			}

			m_entity->add(temp_list);

			// Callback
			call(function_type::client, function_action::refresh, m_entity);
			call(function_type::browse, function_action::refresh, m_entity);
			call(function_type::message, function_action::refresh, m_entity);
		}

		// Response
		return response.get_status();
	}
}

max_stars_repo_name: demonsaw/Code

max_issues_repo_name: demonsaw/Code

max_forks_repo_name: demonsaw/Code


text:
#include "export.hpp"

#include <boost/algorithm/string.hpp>

#include "hyrise.hpp"
#include "import_export/binary/binary_writer.hpp"
#include "import_export/csv/csv_writer.hpp"
#include "utils/assert.hpp"

namespace opossum {

Export::Export(const std::shared_ptr<const AbstractOperator>& in, const std::string& filename,
               const FileType& file_type)
    : AbstractReadOnlyOperator(OperatorType::Export, in), _filename(filename), _file_type(file_type) {
  if (_file_type == FileType::Auto) {
    _file_type = file_type_from_filename(filename);
  }
}

const std::string& Export::name() const {
  static const auto name = std::string{"Export"};
  return name;
}

std::shared_ptr<const Table> Export::_on_execute() {
  if (_filename.empty() || std::all_of(_filename.begin(), _filename.end(), isspace)) {
    Fail("Export: File name must not be empty.");
  }

  switch (_file_type) {
    case FileType::Csv:
      CsvWriter::write(*left_input_table(), _filename);
      break;
    case FileType::Binary:
      BinaryWriter::write(*left_input_table(), _filename);
      break;
    case FileType::Auto:
    case FileType::Tbl:
      Fail("Export: Exporting file type is not supported.");
  }

  // must match ExportNode::output_expressions
  return nullptr;
}

std::shared_ptr<AbstractOperator> Export::_on_deep_copy(
    const std::shared_ptr<AbstractOperator>& copied_left_input,
    const std::shared_ptr<AbstractOperator>& copied_right_input,
    std::unordered_map<const AbstractOperator*, std::shared_ptr<AbstractOperator>>& copied_ops) const {
  return std::make_shared<Export>(copied_left_input, _filename, _file_type);
}

void Export::_on_set_parameters(const std::unordered_map<ParameterID, AllTypeVariant>& parameters) {}

}  // namespace opossum

max_stars_repo_name: mrcl-tst/hyrise

max_issues_repo_name: mrcl-tst/hyrise

max_forks_repo_name: mrcl-tst/hyrise