mirror of
https://github.com/ToruNiina/toml11.git
synced 2024-11-22 20:30:11 +00:00
Merge branch 'workaround-gcc-48x'
This commit is contained in:
commit
c34001725c
24
.travis.yml
24
.travis.yml
@ -2,6 +2,30 @@ dist: trusty
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
language: cpp
|
||||
compiler: gcc
|
||||
env: COMPILER="g++-4.8" CXX_STANDARD=11
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- sourceline: 'ppa:ubuntu-toolchain-r/test'
|
||||
- sourceline: 'ppa:mhier/libboost-latest'
|
||||
packages:
|
||||
- g++-4.8
|
||||
- boost1.70
|
||||
- os: linux
|
||||
language: cpp
|
||||
compiler: gcc
|
||||
env: COMPILER="g++-4.9" CXX_STANDARD=11
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- sourceline: 'ppa:ubuntu-toolchain-r/test'
|
||||
- sourceline: 'ppa:mhier/libboost-latest'
|
||||
packages:
|
||||
- g++-4.9
|
||||
- boost1.70
|
||||
- os: linux
|
||||
language: cpp
|
||||
compiler: gcc
|
||||
|
@ -81,6 +81,54 @@ struct preserve_comments
|
||||
void assign(std::initializer_list<std::string> ini) {comments.assign(ini);}
|
||||
void assign(size_type n, const std::string& val) {comments.assign(n, val);}
|
||||
|
||||
// Related to the issue #97.
|
||||
//
|
||||
// It is known that `std::vector::insert` and `std::vector::erase` in
|
||||
// the standard library implementation included in GCC 4.8.5 takes
|
||||
// `std::vector::iterator` instead of `std::vector::const_iterator`.
|
||||
// Because of the const-correctness, we cannot convert a `const_iterator` to
|
||||
// an `iterator`. It causes compilation error in GCC 4.8.5.
|
||||
#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) && !defined(__clang__)
|
||||
# if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) <= 40805
|
||||
# define TOML11_WORKAROUND_GCC_4_8_X_STANDARD_LIBRARY_IMPLEMENTATION
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef TOML11_WORKAROUND_GCC_4_8_X_STANDARD_LIBRARY_IMPLEMENTATION
|
||||
iterator insert(iterator p, const std::string& x)
|
||||
{
|
||||
return comments.insert(p, x);
|
||||
}
|
||||
iterator insert(iterator p, std::string&& x)
|
||||
{
|
||||
return comments.insert(p, std::move(x));
|
||||
}
|
||||
void insert(iterator p, size_type n, const std::string& x)
|
||||
{
|
||||
return comments.insert(p, n, x);
|
||||
}
|
||||
template<typename InputIterator>
|
||||
void insert(iterator p, InputIterator first, InputIterator last)
|
||||
{
|
||||
return comments.insert(p, first, last);
|
||||
}
|
||||
void insert(iterator p, std::initializer_list<std::string> ini)
|
||||
{
|
||||
return comments.insert(p, ini);
|
||||
}
|
||||
|
||||
template<typename ... Ts>
|
||||
iterator emplace(iterator p, Ts&& ... args)
|
||||
{
|
||||
return comments.emplace(p, std::forward<Ts>(args)...);
|
||||
}
|
||||
|
||||
iterator erase(iterator pos) {return comments.erase(pos);}
|
||||
iterator erase(iterator first, iterator last)
|
||||
{
|
||||
return comments.erase(first, last);
|
||||
}
|
||||
#else
|
||||
iterator insert(const_iterator p, const std::string& x)
|
||||
{
|
||||
return comments.insert(p, x);
|
||||
@ -114,6 +162,7 @@ struct preserve_comments
|
||||
{
|
||||
return comments.erase(first, last);
|
||||
}
|
||||
#endif
|
||||
|
||||
void swap(preserve_comments& other) {comments.swap(other.comments);}
|
||||
|
||||
|
@ -20,11 +20,24 @@ namespace detail
|
||||
{
|
||||
|
||||
// to show error messages. not recommended for users.
|
||||
template<typename C, template<typename ...> class T, template<typename ...> class A>
|
||||
region_base const& get_region(const basic_value<C, T, A>&);
|
||||
template<typename Region,
|
||||
typename C, template<typename ...> class T, template<typename ...> class A>
|
||||
void change_region(basic_value<C, T, A>&, Region&&);
|
||||
template<typename Value>
|
||||
inline region_base const& get_region(const Value& v)
|
||||
{
|
||||
return *(v.region_info_);
|
||||
}
|
||||
|
||||
template<typename Value, typename Region>
|
||||
void change_region(Value& v, Region&& reg)
|
||||
{
|
||||
using region_type = typename std::remove_reference<
|
||||
typename std::remove_cv<Region>::type
|
||||
>::type;
|
||||
|
||||
std::shared_ptr<region_base> new_reg =
|
||||
std::make_shared<region_type>(std::forward<region_type>(reg));
|
||||
v.region_info_ = new_reg;
|
||||
return;
|
||||
}
|
||||
|
||||
template<value_t Expected,
|
||||
typename C, template<typename ...> class T, template<typename ...> class A>
|
||||
@ -1724,13 +1737,11 @@ class basic_value
|
||||
}
|
||||
|
||||
// for error messages
|
||||
template<typename C,
|
||||
template<typename ...> class T, template<typename ...> class A>
|
||||
friend region_base const& detail::get_region(const basic_value<C, T, A>&);
|
||||
template<typename Value>
|
||||
friend region_base const& detail::get_region(const Value& v);
|
||||
|
||||
template<typename Region, typename C,
|
||||
template<typename ...> class T, template<typename ...> class A>
|
||||
friend void detail::change_region(basic_value<C, T, A>&, Region&&);
|
||||
template<typename Value, typename Region>
|
||||
friend void detail::change_region(Value& v, Region&& reg);
|
||||
|
||||
private:
|
||||
|
||||
@ -1760,30 +1771,6 @@ using value = basic_value<discard_comments, std::unordered_map, std::vector>;
|
||||
using array = typename value::array_type;
|
||||
using table = typename value::table_type;
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template<typename C,
|
||||
template<typename ...> class T, template<typename ...> class A>
|
||||
inline region_base const& get_region(const basic_value<C, T, A>& v)
|
||||
{
|
||||
return *(v.region_info_);
|
||||
}
|
||||
|
||||
template<typename Region, typename C,
|
||||
template<typename ...> class T, template<typename ...> class A>
|
||||
void change_region(basic_value<C, T, A>& v, Region&& reg)
|
||||
{
|
||||
using region_type = typename std::remove_reference<
|
||||
typename std::remove_cv<Region>::type
|
||||
>::type;
|
||||
|
||||
std::shared_ptr<region_base> new_reg =
|
||||
std::make_shared<region_type>(std::forward<region_type>(reg));
|
||||
v.region_info_ = new_reg;
|
||||
return;
|
||||
}
|
||||
}// detail
|
||||
|
||||
template<typename C, template<typename ...> class T, template<typename ...> class A>
|
||||
inline bool
|
||||
operator==(const basic_value<C, T, A>& lhs, const basic_value<C, T, A>& rhs)
|
||||
|
Loading…
Reference in New Issue
Block a user