Commit ebada328 authored by Shu's avatar Shu 🍠
Browse files

Windows compat

parent 18c840b9
.vscode
build
build*
docs
external
resource/*/.*
\ No newline at end of file
......@@ -8,6 +8,7 @@ option(USE_FMA "Use fma" 1)
option(LOG_DEBUG "Show debug logs" 0)
option(LOG_TRACE "Show trace logs" 0)
option(NATIVE "Build with -march=native" 0)
option(GL_OLD "Use OpenGL 4.2 not 4.6" 0)
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
......@@ -23,10 +24,15 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
if(WIN32)
add_definitions(/std:c++latest)
add_compile_definitions(WIN32_LEAN_AND_MEAN=)
else()
set(CMAKE_CXX_FLAGS "-Wall -Wextra")
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_compile_definitions(FIXED_WINDOW=${FIXED_WINDOW} LOG_DEBUG=${LOG_DEBUG} LOG_TRACE=${LOG_TRACE} HN_USE_FILESYSTEM=1)
add_compile_definitions(FIXED_WINDOW=${FIXED_WINDOW} LOG_DEBUG=${LOG_DEBUG} LOG_TRACE=${LOG_TRACE} GL_OLD=${GL_OLD} HN_USE_FILESYSTEM=1)
if(PROFILING)
add_compile_definitions(TRACY_ENABLE=1)
endif(PROFILING)
......@@ -38,23 +44,39 @@ if(SIMD_LEVEL EQUAL "avx2")
elseif(SIMD_LEVEL EQUAL "avx512f")
add_compile_definitions(FN_COMPILE_AVX512=1)
endif()
add_definitions(-m${SIMD_LEVEL})
if(WIN32)
add_definitions(/arch:AVX2)
else()
add_definitions(-m${SIMD_LEVEL})
endif()
if(USE_FMA)
add_definitions(-mfma)
if(WIN32)
add_definitions(/GL /fp:fast)
else()
add_definitions(-mfma)
endif()
endif(USE_FMA)
file(GLOB_RECURSE CORE_SOURCES "src/core/*.cpp" "deps/tracy/TracyClient.cpp")
set(CORE_HEADERS "deps/toml++" "deps/robin_hood" "deps/libguarded" "deps/tracy")
set(CORE_LIBS pthread dl glm::glm_static picoquic-core zstd::zstd_static)
set(CORE_LIBS glm::glm_static zstd::zstd_static) # picoquic
file(GLOB_RECURSE CLIENT_SOURCES "src/client/*.cpp" "deps/imgui/*.cpp" "deps/meshoptimizer/*.cpp" "deps/gl3w/gl3w.c" "deps/volk/volk.c")
set(CLIENT_HEADERS "deps/imgui" "deps/meshoptimizer" "deps/gl3w" "deps/volk")
set(CLIENT_HEADERS "deps/imgui" "deps/meshoptimizer" "deps/gl3w" "deps/volk") # vulkan
set(CLIENT_LIBS glfw)
file(GLOB_RECURSE SERVER_SOURCES "src/server/*.cpp" "deps/FastNoiseSIMD/*.cpp")
set(SERVER_HEADERS "deps/FastNoiseSIMD")
set(SERVER_LINKED)
if(WIN32)
set(CLIENT_HEADERS ${CLIENT_HEADERS} $ENV{VULKAN_SDK}\\include)
find_package(OpenSSL)
set(CORE_LIBS ${CORE_LIBS} ${CMAKE_BINARY_DIR}/libs/*.lib ${OPENSSL_LIBRARIES} ws2_32)
else()
set(CORE_LIBS ${CORE_LIBS} picoquic-core pthread dl)
endif()
# All in one exec
add_executable(univerxel "src/main.cpp" ${CORE_SOURCES} ${CLIENT_SOURCES} ${SERVER_SOURCES})
target_compile_features(univerxel PUBLIC cxx_std_17)
......
......@@ -14,6 +14,7 @@ Work in progress galaxy down to atom (mostly centimeter) online voxel game
- [Optionally](#optionally)
- [Installation](#installation)
- [Additionally](#additionally)
- [Windows](#windows)
- [RoadMap](#roadmap)
- [License](#license)
- [Contact](#contact)
......@@ -102,6 +103,7 @@ PROFILING | Tracy profiling | `0`
LOG_DEBUG | Debug logs | `0`
LOG_TRACE | Trace logs | `0`
NATIVE | Optimize for native CPU | `0`
GL_OLD | Use OpenGL 4.2 not 4.6 | `0`
1. Build Make
```sh
......@@ -132,6 +134,14 @@ cd resource/textures-src
./merge.py <args> # Combine grey images to RGB
```
### Windows
1. Setup Visual Studio 2017+ with C++
2. Clone picotls and picoquic in a separate directory
3. Set `%OPENSSL64DIR%` and check `WindowsPort.md` and `Readme.md` note from respective library
4. Compile then with MsBuild
5. Copy picoquic.lib, picotls-openssl.lib and picotls-fusion.lib to build/libs
6. Build univerxel with cmake `-A x64` and MsBuild
<!-- ROADMAP -->
## RoadMap
......
......@@ -46,6 +46,9 @@
- [~] CI build
- [ ] CMake package
- [x] GitLab CI
- Platfoms
- [x] Linux
- [~] Windows
- [ ] Universe
- [ ] Galaxy
- [ ] Rotation
......@@ -107,5 +110,6 @@
- [ ] Deferred
- [ ] Cascaded shadow maps
- [ ] Ray Tracing
- [ ] Avoid transparent back-face
- [ ] Translucency
- Back face Depth based
......@@ -4,45 +4,6 @@ cmake_policy(SET CMP0048 NEW)
project(picoquic VERSION 0.0.1 LANGUAGES C CXX)
find_package (Threads REQUIRED)
add_subdirectory("picotls")
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_FLAGS "-std=c99 -Wall -Werror -O2 -g ${CC_WARNING_FLAGS} ${CMAKE_C_FLAGS}")
if(DISABLE_DEBUG_PRINTF)
set(CMAKE_C_FLAGS "-DDISABLE_DEBUG_PRINTF ${CMAKE_C_FLAGS}")
endif()
set(PICOQUIC_LIBRARY_FILES
bbr.c
bytestream.c
cc_common.c
cubic.c
fastcc.c
frames.c
intformat.c
logger.c
logwriter.c
newreno.c
packet.c
picohash.c
picosocks.c
picosplay.c
quicctx.c
sacks.c
sender.c
sim_link.c
sockloop.c
spinbit.c
ticket_store.c
token_store.c
tls_api.c
transport.c
unified_log.c
util.c
)
set(PICOQUIC_CORE_HEADERS
picoquic.h
picosocks.h
......@@ -56,5 +17,50 @@ set(PICOQUIC_CORE_HEADERS
find_package(OpenSSL)
include_directories(picoquic "picotls/include" ${OPENSSL_INCLUDE_DIR})
add_library(picoquic-core ${PICOQUIC_CORE_HEADERS} ${PICOQUIC_LIBRARY_FILES})
target_link_libraries(picoquic-core picotls-core picotls-openssl picotls-fusion ${OPENSSL_LIBRARIES})
if(WIN32)
MESSAGE(WARNING "Please build picoquic and picotls with Visual Studio")
MESSAGE(WARNING "Then put picoquic.lib, picotls-core.lib picotls-openssl.lib and picotls-fusion.lib in build/libs")
else()
add_subdirectory("picotls")
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_FLAGS "-std=c99 -O2 -g ${CC_WARNING_FLAGS} ${CMAKE_C_FLAGS}")
if(DISABLE_DEBUG_PRINTF)
set(CMAKE_C_FLAGS "-DDISABLE_DEBUG_PRINTF ${CMAKE_C_FLAGS}")
endif()
set(PICOQUIC_LIBRARY_FILES
bbr.c
bytestream.c
cc_common.c
cubic.c
fastcc.c
frames.c
intformat.c
logger.c
logwriter.c
newreno.c
packet.c
picohash.c
picosocks.c
picosplay.c
quicctx.c
sacks.c
sender.c
sim_link.c
sockloop.c
spinbit.c
ticket_store.c
token_store.c
tls_api.c
transport.c
unified_log.c
util.c
)
add_library(picoquic-core ${PICOQUIC_CORE_HEADERS} ${PICOQUIC_LIBRARY_FILES})
target_link_libraries(picoquic-core picotls-core picotls-openssl picotls-fusion ${OPENSSL_LIBRARIES})
endif()
MIT License
Copyright (c) 2019-2020 Mark Gillard <mark.gillard@outlook.com.au>
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.
#define TOML_HEADER_ONLY 0
//# This file is a part of toml++ and is subject to the the terms of the MIT license.
//# Copyright (c) 2019-2020 Mark Gillard <mark.gillard@outlook.com.au>
//# See https://github.com/marzer/tomlplusplus/blob/master/LICENSE for the full license text.
// SPDX-License-Identifier: MIT
//# {{
#ifndef INCLUDE_TOMLPLUSPLUS_H
#define INCLUDE_TOMLPLUSPLUS_H
//# }}
//# Note: most of these would be included transitively but
//# they're listed explicitly here because this file
//# is used as the source for generate_single_header.py.
#include "toml_preprocessor.h"
TOML_PUSH_WARNINGS
TOML_DISABLE_SPAM_WARNINGS
#include "toml_common.h"
#include "toml_date_time.h"
#include "toml_print_to_stream.h"
......@@ -22,7 +23,6 @@
#include "toml_array.h"
#include "toml_table.h"
#include "toml_node_view.h"
#include "toml_utf8_generated.h"
#include "toml_utf8.h"
#include "toml_formatter.h"
#include "toml_default_formatter.h"
......@@ -40,68 +40,109 @@
#include "toml_default_formatter.hpp"
#include "toml_json_formatter.hpp"
#if TOML_PARSER
#include "toml_utf8_streams.hpp"
#include "toml_parser.hpp"
#endif // TOML_PARSER
#if !TOML_ALL_INLINE
#if !TOML_HEADER_ONLY
#include "toml_instantiations.hpp"
#endif // !TOML_ALL_INLINE
#endif // !TOML_HEADER_ONLY
#endif // TOML_IMPLEMENTATION
TOML_POP_WARNINGS // TOML_DISABLE_SPAM_WARNINGS
// macro hygiene
#if TOML_UNDEF_MACROS
#undef TOML_INT_CHARCONV
#undef TOML_FLOAT_CHARCONV
#undef TOML_ABI_NAMESPACES
#undef TOML_ABI_NAMESPACE_BOOL
#undef TOML_ABI_NAMESPACE_END
#undef TOML_ABI_NAMESPACE_START
#undef TOML_ALWAYS_INLINE
#undef TOML_ANON_NAMESPACE
#undef TOML_ANON_NAMESPACE_END
#undef TOML_ANON_NAMESPACE_START
#undef TOML_ARM
#undef TOML_ASSERT
#undef TOML_ASSUME
#undef TOML_ASYMMETRICAL_EQUALITY_OPS
#undef TOML_ATTR
#undef TOML_PUSH_WARNINGS
#undef TOML_DISABLE_SWITCH_WARNINGS
#undef TOML_CLANG
#undef TOML_COMPILER_EXCEPTIONS
#undef TOML_CONCAT
#undef TOML_CONCAT_1
#undef TOML_CONSTEVAL
#undef TOML_CPP
#undef TOML_DISABLE_ARITHMETIC_WARNINGS
#undef TOML_DISABLE_INIT_WARNINGS
#undef TOML_DISABLE_VTABLE_WARNINGS
#undef TOML_DISABLE_PADDING_WARNINGS
#undef TOML_DISABLE_FLOAT_WARNINGS
#undef TOML_DISABLE_SPAM_WARNINGS
#undef TOML_DISABLE_SHADOW_WARNINGS
#undef TOML_DISABLE_SUGGEST_WARNINGS
#undef TOML_DISABLE_ALL_WARNINGS
#undef TOML_POP_WARNINGS
#undef TOML_ALWAYS_INLINE
#undef TOML_NEVER_INLINE
#undef TOML_ASSUME
#undef TOML_UNREACHABLE
#undef TOML_INTERFACE
#undef TOML_DISABLE_SWITCH_WARNINGS
#undef TOML_DISABLE_WARNINGS
#undef TOML_ENABLE_WARNINGS
#undef TOML_EMPTY_BASES
#undef TOML_CPP_VERSION
#undef TOML_CPP
#undef TOML_MAY_THROW
#undef TOML_NO_DEFAULT_CASE
#undef TOML_CONSTEVAL
#undef TOML_LIKELY
#undef TOML_UNLIKELY
#undef TOML_NODISCARD_CTOR
#undef TOML_MAKE_VERSION
#undef TOML_EVAL_BOOL_0
#undef TOML_EVAL_BOOL_1
#undef TOML_EXTERNAL_LINKAGE
#undef TOML_FLOAT128
#undef TOML_FLOAT16
#undef TOML_FLOAT_CHARCONV
#undef TOML_FP16
#undef TOML_GCC
#undef TOML_HAS_ATTR
#undef TOML_HAS_CUSTOM_OPTIONAL_TYPE
#undef TOML_HAS_INCLUDE
#undef TOML_ICC
#undef TOML_ICC_CL
#undef TOML_IMPLEMENTATION
#undef TOML_IMPL_NAMESPACE_END
#undef TOML_IMPL_NAMESPACE_START
#undef TOML_INT128
#undef TOML_INTELLISENSE
#undef TOML_INTERFACE
#undef TOML_INTERNAL_LINKAGE
#undef TOML_INT_CHARCONV
#undef TOML_LANG_AT_LEAST
#undef TOML_LANG_EFFECTIVE_VERSION
#undef TOML_LANG_HIGHER_THAN
#undef TOML_LANG_AT_LEAST
#undef TOML_LANG_UNRELEASED
#undef TOML_STRING_PREFIX_1
#undef TOML_STRING_PREFIX
#undef TOML_UNDEF_MACROS
#undef TOML_RELOPS_REORDERING
#undef TOML_ASYMMETRICAL_EQUALITY_OPS
#undef TOML_ALL_INLINE
#undef TOML_IMPLEMENTATION
#undef TOML_EXTERNAL_LINKAGE
#undef TOML_INTERNAL_LINKAGE
#undef TOML_INTERNAL_NAMESPACE
#undef TOML_COMPILER_EXCEPTIONS
#undef TOML_TRIVIAL_ABI
#undef TOML_ABI_NAMESPACES
#undef TOML_ABI_NAMESPACE_START
#undef TOML_ABI_NAMESPACE_END
#undef TOML_PARSER_TYPENAME
#undef TOML_LAUNDER
#undef TOML_LIFETIME_HOOKS
#undef TOML_LIKELY
#undef TOML_MAKE_BITOPS
#undef TOML_MAKE_VERSION
#undef TOML_MAY_THROW
#undef TOML_MSVC
#undef TOML_NAMESPACE
#undef TOML_NAMESPACE_END
#undef TOML_NAMESPACE_START
#undef TOML_NEVER_INLINE
#undef TOML_NODISCARD_CTOR
#undef TOML_NO_DEFAULT_CASE
#undef TOML_PARSER_TYPENAME
#undef TOML_POP_WARNINGS
#undef TOML_PUSH_WARNINGS
#undef TOML_SA_LIST_BEG
#undef TOML_SA_LIST_END
#undef TOML_SA_LIST_NEW
#undef TOML_SA_LIST_NXT
#undef TOML_SA_LIST_SEP
#undef TOML_SA_NATIVE_VALUE_TYPE_LIST
#undef TOML_SA_NEWLINE
#undef TOML_SA_NODE_TYPE_LIST
#undef TOML_SA_UNWRAPPED_NODE_TYPE_LIST
#undef TOML_SA_VALUE_EXACT_FUNC_MESSAGE
#undef TOML_SA_VALUE_FUNC_MESSAGE
#undef TOML_SA_VALUE_MESSAGE_CONST_CHAR8
#undef TOML_SA_VALUE_MESSAGE_U8STRING_VIEW
#undef TOML_SA_VALUE_MESSAGE_WSTRING
#undef TOML_SIMPLE_STATIC_ASSERT_MESSAGES
#undef TOML_TRIVIAL_ABI
#undef TOML_UINT128
#undef TOML_UNLIKELY
#undef TOML_UNREACHABLE
#undef TOML_USING_ANON_NAMESPACE
#endif
//# {{
#endif // INCLUDE_TOMLPLUSPLUS_H
//# }}
This diff is collapsed.
......@@ -13,41 +13,104 @@
#include "toml_array.h"
TOML_PUSH_WARNINGS
TOML_DISABLE_SUGGEST_WARNINGS
namespace toml
TOML_NAMESPACE_START
{
#if TOML_LIFETIME_HOOKS
TOML_EXTERNAL_LINKAGE
void array::preinsertion_resize(size_t idx, size_t count) noexcept
void array::lh_ctor() noexcept
{
const auto new_size = values.size() + count;
const auto inserting_at_end = idx == values.size();
values.resize(new_size);
if (!inserting_at_end)
{
for (size_t r = new_size, e = idx + count, l = e; r-- > e; l--)
values[r] = std::move(values[l]);
}
TOML_ARRAY_CREATED;
}
TOML_EXTERNAL_LINKAGE
array::array() noexcept = default;
void array::lh_dtor() noexcept
{
TOML_ARRAY_DESTROYED;
}
#endif
TOML_EXTERNAL_LINKAGE
array::array() noexcept
{
#if TOML_LIFETIME_HOOKS
lh_ctor();
#endif
}
TOML_EXTERNAL_LINKAGE
array::array(const array& other) noexcept
: node{ other }
{
elements.reserve(other.elements.size());
for (const auto& elem : other)
elements.emplace_back(impl::make_node(elem));
#if TOML_LIFETIME_HOOKS
lh_ctor();
#endif
}
TOML_EXTERNAL_LINKAGE
array::array(array&& other) noexcept
: node{ std::move(other) },
values{ std::move(other.values) }
{}
elements{ std::move(other.elements) }
{
#if TOML_LIFETIME_HOOKS
lh_ctor();
#endif
}
TOML_EXTERNAL_LINKAGE
array& array::operator= (const array& rhs) noexcept
{
if (&rhs != this)
{
node::operator=(rhs);
elements.clear();
elements.reserve(rhs.elements.size());
for (const auto& elem : rhs)
elements.emplace_back(impl::make_node(elem));
}
return *this;
}
TOML_EXTERNAL_LINKAGE
array& array::operator= (array&& rhs) noexcept
{
node::operator=(std::move(rhs));
values = std::move(rhs.values);
if (&rhs != this)
{
node::operator=(std::move(rhs));
elements = std::move(rhs.elements);
}
return *this;
}
TOML_EXTERNAL_LINKAGE
array::~array() noexcept
{
#if TOML_LIFETIME_HOOKS
lh_dtor();
#endif
}
TOML_EXTERNAL_LINKAGE
void array::preinsertion_resize(size_t idx, size_t count) noexcept
{
TOML_ASSERT(idx <= elements.size());
TOML_ASSERT(count >= 1_sz);
const auto old_size = elements.size();
const auto new_size = old_size + count;
const auto inserting_at_end = idx == old_size;
elements.resize(new_size);
if (!inserting_at_end)
{
for(size_t left = old_size, right = new_size - 1_sz; left --> idx; right--)
elements[right] = std::move(elements[left]);
}
}
#define TOML_MEMBER_ATTR(attr) TOML_EXTERNAL_LINKAGE TOML_ATTR(attr)
TOML_MEMBER_ATTR(const) node_type array::type() const noexcept { return node_type::array; }
......@@ -57,69 +120,122 @@ namespace toml
TOML_MEMBER_ATTR(const) const array* array::as_array() const noexcept { return this; }
TOML_MEMBER_ATTR(const) array* array::as_array() noexcept { return this; }
TOML_MEMBER_ATTR(pure) const node& array::operator[] (size_t index) const noexcept { return *values[index]; }
TOML_MEMBER_ATTR(pure) node& array::operator[] (size_t index) noexcept { return *values[index]; }
TOML_MEMBER_ATTR(pure) const node& array::operator[] (size_t index) const noexcept { return *elements[index]; }
TOML_MEMBER_ATTR(pure) node& array::operator[] (size_t index) noexcept { return *elements[index]; }
TOML_MEMBER_ATTR(pure) const node& array::front() const noexcept { return *values.front(); }
TOML_MEMBER_ATTR(pure) const node& array::back() const noexcept { return *values.back(); }
TOML_MEMBER_ATTR(pure) node& array::front() noexcept { return *values.front(); }
TOML_MEMBER_ATTR(pure) node& array::back() noexcept { return *values.back(); }
TOML_MEMBER_ATTR(pure) const node& array::front() const noexcept { return *elements.front(); }
TOML_MEMBER_ATTR(pure) const node& array::back() const noexcept { return *elements.back(); }
TOML_MEMBER_ATTR(pure) node& array::front() noexcept { return *elements.front(); }
TOML_MEMBER_ATTR(pure) node& array::back() noexcept { return *elements.back(); }
TOML_MEMBER_ATTR(pure) array::const_iterator array::begin() const noexcept { return { values.begin() }; }
TOML_MEMBER_ATTR(pure) array::const_iterator array::end() const noexcept { return { values.end() }; }
TOML_MEMBER_ATTR(pure) array::const_iterator array::cbegin() const noexcept { return { values.cbegin() }; }
TOML_MEMBER_ATTR(pure) array::const_iterator array::cend() const noexcept { return { values.cend() }; }
TOML_MEMBER_ATTR(pure) array::iterator array::begin() noexcept { return { values.begin() }; }
TOML_MEMBER_ATTR(pure) array::iterator array::end() noexcept { return { values.end() }; }
TOML_MEMBER_ATTR(pure) array::const_iterator array::begin() const noexcept { return { elements.begin() }; }
TOML_MEMBER_ATTR(pure) array::const_iterator array::end() const noexcept { return { elements.end() }; }
TOML_MEMBER_ATTR(pure) array::const_iterator array::cbegin() const noexcept { return { elements.cbegin() }; }
TOML_MEMBER_ATTR(pure) array::const_iterator array::cend() const noexcept { return { elements.cend() }; }
TOML_MEMBER_ATTR(pure) array::iterator array::begin() noexcept { return { elements.begin() }; }
TOML_MEMBER_ATTR(pure) array::iterator array::end() noexcept { return { elements.end() }; }
TOML_MEMBER_ATTR(pure) size_t array::size() const noexcept { return values.size(); }
TOML_MEMBER_ATTR(pure) size_t array::capacity() const noexcept { return values.capacity(); }
TOML_MEMBER_ATTR(pure) bool array::empty() const noexcept { return values.empty(); }
TOML_MEMBER_ATTR(const) size_t array::max_size() const noexcept { return values.max_size(); }
TOML_MEMBER_ATTR(pure) size_t array::size() const noexcept { return elements.size(); }
TOML_MEMBER_ATTR(pure) size_t array::capacity() const noexcept { return elements.capacity(); }
TOML_MEMBER_ATTR(pure) bool array::empty() const noexcept { return elements.empty(); }
TOML_MEMBER_ATTR(const) size_t array::max_size() const noexcept { return elements.max_size(); }
TOML_EXTERNAL_LINKAGE void array::reserve(size_t new_capacity) { values.reserve(new_capacity); }
TOML_EXTERNAL_LINKAGE void array::clear() noexcept { values.clear(); }
TOML_EXTERNAL_LINKAGE void array::shrink_to_fit() { values.shrink_to_fit(); }
TOML_EXTERNAL_LINKAGE void array::reserve(size_t new_capacity) { elements.reserve(new_capacity); }
TOML_EXTERNAL_LINKAGE void array::clear() noexcept { elements.clear(); }
TOML_EXTERNAL_LINKAGE void array::shrink_to_fit() { elements.shrink_to_fit(); }
#undef TOML_MEMBER_ATTR
TOML_EXTERNAL_LINKAGE
bool array::is_homogeneous(node_type ntype) const noexcept
{
if (elements.empty())
return false;
if (ntype == node_type::none)
ntype = elements[0]->type();
for (const auto& val : elements)
if (val->type() != ntype)
return false;
return true;
}
namespace impl
{
template <typename T, typename U>
TOML_INTERNAL_LINKAGE
bool array_is_homogeneous(T& elements, node_type ntype, U& first_nonmatch) noexcept
{
if (elements.empty())
{
first_nonmatch = {};
return false;
}
if (ntype == node_type::none)
ntype = elements[0]->type();
for (const auto& val : elements)