mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
Visual Studio 2013 compilation fixes.
- Missing header file callouts in some cases (library deltas) - Lack of support for auto parameters in lambdas - Defining of ERROR by windows.h - Dispatcher::Connection needs a move constructor (default not generated) - Need explicit enable_if on std::string move template in Value to avoid trying to move const char[] (string literal) - Compile flags
This commit is contained in:
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8)
|
||||
project(ntcore)
|
||||
|
||||
if (MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -pedantic -Wno-unused-parameter")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DNOMINMAX /D_SCL_SECURE_NO_WARNINGS")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -Wformat=2 -Wall -Wextra -Werror -pedantic -Wno-unused-parameter")
|
||||
endif()
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#define LLVM_ADT_STRINGEXTRAS_H
|
||||
|
||||
#include "llvm/StringRef.h"
|
||||
#include <cstdint>
|
||||
#include <iterator>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
@@ -10,7 +10,8 @@ class NetworkTable : public ITable {
|
||||
struct private_init {};
|
||||
|
||||
std::string m_path;
|
||||
std::vector<std::pair<ITableListener*, unsigned int>> m_listeners;
|
||||
typedef std::pair<ITableListener*, unsigned int> Listener;
|
||||
std::vector<Listener> m_listeners;
|
||||
|
||||
static std::string s_ip_address;
|
||||
static bool s_client;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include "llvm/ArrayRef.h"
|
||||
@@ -103,7 +104,7 @@ class Value {
|
||||
val->m_val.data.v_string.len = val->m_string.size();
|
||||
return val;
|
||||
}
|
||||
template <typename T>
|
||||
template <typename T, typename = std::enable_if_t<std::is_same<T, std::string>>>
|
||||
static std::shared_ptr<Value> MakeString(T&& value) {
|
||||
auto val = std::make_shared<Value>(NT_STRING, private_init());
|
||||
val->m_string = std::move(value);
|
||||
@@ -118,7 +119,7 @@ class Value {
|
||||
val->m_val.data.v_raw.len = val->m_string.size();
|
||||
return val;
|
||||
}
|
||||
template <typename T>
|
||||
template <typename T, typename = std::enable_if_t<std::is_same<T, std::string>>>
|
||||
static std::shared_ptr<Value> MakeRaw(T&& value) {
|
||||
auto val = std::make_shared<Value>(NT_RAW, private_init());
|
||||
val->m_string = std::move(value);
|
||||
|
||||
@@ -85,6 +85,13 @@ class DispatcherBase {
|
||||
Connection() = default;
|
||||
explicit Connection(std::unique_ptr<NetworkConnection> net_)
|
||||
: net(std::move(net_)) {}
|
||||
Connection(Connection&& rhs) {
|
||||
net = std::move(rhs.net);
|
||||
outgoing = std::move(rhs.outgoing);
|
||||
last_update = std::move(rhs.last_update);
|
||||
}
|
||||
Connection(const Connection&) = delete;
|
||||
Connection& operator=(const Connection&) = delete;
|
||||
void QueueOutgoing(std::shared_ptr<Message> msg);
|
||||
|
||||
std::unique_ptr<NetworkConnection> net;
|
||||
|
||||
@@ -60,6 +60,7 @@ class Logger {
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#undef ERROR
|
||||
#define ERROR(x) LOG(NT_LOG_ERROR, x)
|
||||
#define WARNING(x) LOG(NT_LOG_WARNING, x)
|
||||
#define INFO(x) LOG(NT_LOG_INFO, x)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "Storage.h"
|
||||
|
||||
#include <cctype>
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
@@ -567,7 +568,8 @@ static void WriteString(std::ostream& os, llvm::StringRef str) {
|
||||
|
||||
void Storage::SavePersistent(std::ostream& os) const {
|
||||
// copy values out of storage as quickly as possible so lock isn't held
|
||||
std::vector<std::pair<std::string, std::shared_ptr<Value>>> entries;
|
||||
typedef std::pair<std::string, std::shared_ptr<Value>> NewEntry;
|
||||
std::vector<NewEntry> entries;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
entries.reserve(m_entries.size());
|
||||
@@ -581,7 +583,7 @@ void Storage::SavePersistent(std::ostream& os) const {
|
||||
|
||||
// sort in name order
|
||||
std::sort(entries.begin(), entries.end(),
|
||||
[](const auto& a, const auto& b) { return a.first < b.first; });
|
||||
[](const NewEntry& a, const NewEntry& b) { return a.first < b.first; });
|
||||
|
||||
std::string base64_encoded;
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ void NetworkTable::AddTableListener(StringRef key,
|
||||
void NetworkTable::RemoveTableListener(ITableListener* listener) {
|
||||
auto matches_begin =
|
||||
std::remove_if(m_listeners.begin(), m_listeners.end(),
|
||||
[=](const auto& x) { return x.first == listener; });
|
||||
[=](const Listener& x) { return x.first == listener; });
|
||||
|
||||
for (auto i = matches_begin; i != m_listeners.end(); ++i)
|
||||
nt::RemoveEntryListener(i->second);
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "llvm/StringRef.h"
|
||||
|
||||
Reference in New Issue
Block a user