Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use custom any implementation #809

Merged
merged 1 commit into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 10 additions & 22 deletions brayns/common/PropertyMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,8 @@
#pragma once

#include <brayns/common/types.h>

// clang-format off
#if __has_include(<any>)
#include <any>
#elif __has_include(<experimental/any>)
#include <experimental/any>
namespace std {
using experimental::any;
using experimental::any_cast;
}
#else
#error no any support
#endif
// clang-format on
// NOTE: Replace with std::any when upgrading to c++17
#include <deps/any.hpp>

#include <algorithm>
#include <functional>
Expand Down Expand Up @@ -247,9 +235,9 @@ struct Property
private:
friend class PropertyMap;

std::any _data;
const std::any _min;
const std::any _max;
linb::any _data;
const linb::any _min;
const linb::any _max;
bool _readOnly{false};
ModifiedCallback _modifiedCallback;

Expand All @@ -262,13 +250,13 @@ struct Property
"'");
}
template <typename T>
T _castValue(const std::any& v) const
T _castValue(const linb::any& v) const
{
_checkType<T>();
return std::any_cast<T>(v);
return linb::any_cast<T>(v);
}

void _setData(const std::any& data)
void _setData(const linb::any& data)
{
_data = data;
if (_modifiedCallback)
Expand Down Expand Up @@ -296,8 +284,8 @@ class PropertyMap
// std::vector move constructor is not noexcept until C++17, if we want
// this class to be movable we have to do it by hand.
PropertyMap(PropertyMap&& other) noexcept
: _name(std::move(other._name)),
_properties(std::move(other._properties))
: _name(std::move(other._name))
, _properties(std::move(other._properties))
{
}
// Assignment operator valid for both copy and move assignment.
Expand Down
Loading