Skip to content

Commit

Permalink
Update project to use C++ 17 as the default standard library.
Browse files Browse the repository at this point in the history
  • Loading branch information
clangen committed Dec 3, 2022
1 parent 733e12a commit 90a92c8
Show file tree
Hide file tree
Showing 22 changed files with 236 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .cmake/ConfigureCompilerFlags.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wno-unused-result -Wno-deprecated-declarations")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wno-unused-result -Wno-deprecated-declarations")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -g -frtti -fexceptions")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG")

Expand Down
2 changes: 1 addition & 1 deletion script/build-vendor-libraries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function fetch_packages() {
function build_boost() {
BOOST_CXX_FLAGS="-fPIC"
if [[ $OS == "Darwin" ]]; then
BOOST_CXX_FLAGS="-fPIC -std=c++14 -stdlib=libc++"
BOOST_CXX_FLAGS="-fPIC -std=c++17 -stdlib=libc++"
fi

tar xvfj boost_${BOOST_VERSION}.tar.bz2
Expand Down
12 changes: 12 additions & 0 deletions src/3rdparty/3rdparty.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@
<ObjectFileName>$(IntDir)</ObjectFileName>
<ProgramDataBaseFileName>$(IntDir)$(ProjectName).pdb</ProgramDataBaseFileName>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug-DLL|Win32'">
Expand All @@ -277,6 +278,7 @@
<ObjectFileName>$(IntDir)</ObjectFileName>
<ProgramDataBaseFileName>$(IntDir)$(ProjectName).pdb</ProgramDataBaseFileName>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Con|Win32'">
Expand All @@ -295,6 +297,7 @@
<ObjectFileName>$(IntDir)</ObjectFileName>
<ProgramDataBaseFileName>$(IntDir)$(ProjectName).pdb</ProgramDataBaseFileName>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand All @@ -313,6 +316,7 @@
<ObjectFileName>$(IntDir)</ObjectFileName>
<ProgramDataBaseFileName>$(IntDir)$(ProjectName).pdb</ProgramDataBaseFileName>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug-DLL|x64'">
Expand All @@ -331,6 +335,7 @@
<ObjectFileName>$(IntDir)</ObjectFileName>
<ProgramDataBaseFileName>$(IntDir)$(ProjectName).pdb</ProgramDataBaseFileName>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug-Con|x64'">
Expand All @@ -349,6 +354,7 @@
<ObjectFileName>$(IntDir)</ObjectFileName>
<ProgramDataBaseFileName>$(IntDir)$(ProjectName).pdb</ProgramDataBaseFileName>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand All @@ -369,6 +375,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<ExceptionHandling>Sync</ExceptionHandling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release-DLL|Win32'">
Expand All @@ -389,6 +396,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<ExceptionHandling>Sync</ExceptionHandling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release-Con|Win32'">
Expand All @@ -409,6 +417,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<ExceptionHandling>Sync</ExceptionHandling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
Expand All @@ -429,6 +438,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<ExceptionHandling>Sync</ExceptionHandling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release-DLL|x64'">
Expand All @@ -449,6 +459,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<ExceptionHandling>Sync</ExceptionHandling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release-Con|x64'">
Expand All @@ -469,6 +480,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<ExceptionHandling>Sync</ExceptionHandling>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
12 changes: 12 additions & 0 deletions src/core_c_demo/core_c_demo.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
<ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeaderFile />
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>../../../boost_1_74_0/lib32-msvc-14.2;../3rdparty/bin/win32/lib;../3rdparty/bin/win32/lib/debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
Expand Down Expand Up @@ -326,6 +327,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>../../../boost_1_74_0/lib32-msvc-14.2;../3rdparty/bin/win32/lib;../3rdparty/bin/win32/lib/debug;$(OutputPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
Expand Down Expand Up @@ -367,6 +369,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>../../../boost_1_74_0/lib32-msvc-14.2;../3rdparty/bin/win32/lib;../3rdparty/bin/win32/lib/debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
Expand Down Expand Up @@ -406,6 +409,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
<ProgramDataBaseFileName>$(IntDir)vc$(PlatformToolsetVersion).pdb</ProgramDataBaseFileName>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeaderFile />
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>../../../boost_1_74_0/lib64-msvc-14.2;../3rdparty/bin/win64/lib;../3rdparty/bin/win64/lib/debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
Expand Down Expand Up @@ -445,6 +449,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>../../../boost_1_74_0/lib64-msvc-14.2;../3rdparty/bin/win64/lib;../3rdparty/bin/win64/lib/debug;$(OutputPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
Expand Down Expand Up @@ -484,6 +489,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>../../../boost_1_74_0/lib64-msvc-14.2;../3rdparty/bin/win64/lib;../3rdparty/bin/win64/lib/debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
Expand Down Expand Up @@ -525,6 +531,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeaderFile />
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>../../../boost_1_74_0/lib32-msvc-14.2;../3rdparty/bin/win32/lib;../3rdparty/bin/win32/lib/release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
Expand Down Expand Up @@ -572,6 +579,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>../../../boost_1_74_0/lib32-msvc-14.2;../3rdparty/bin/win32/lib;../3rdparty/bin/win32/lib/release;$(OutputPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
Expand Down Expand Up @@ -619,6 +627,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>../../../boost_1_74_0/lib32-msvc-14.2;../3rdparty/bin/win32/lib;../3rdparty/bin/win32/lib/release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
Expand Down Expand Up @@ -665,6 +674,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeaderFile />
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>../../../boost_1_74_0/lib64-msvc-14.2;../3rdparty/bin/win64/lib;../3rdparty/bin/win64/lib/release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
Expand Down Expand Up @@ -711,6 +721,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>../../../boost_1_74_0/lib64-msvc-14.2;../3rdparty/bin/win64/lib;../3rdparty/bin/win64/lib/release;$(OutputPath);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
Expand Down Expand Up @@ -757,6 +768,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
<ExceptionHandling>Sync</ExceptionHandling>
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>../../../boost_1_74_0/lib64-msvc-14.2;../3rdparty/bin/win64/lib;../3rdparty/bin/win64/lib/release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
Expand Down
7 changes: 6 additions & 1 deletion src/musikcore/library/track/TrackList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@
#include <musikcore/support/NarrowCast.h>
#include <unordered_set>
#include <map>
#include <random>
#include <chrono>

using namespace musik::core;
using namespace musik::core::db;
using namespace musik::core::library;
using namespace musik::core::library::query;
using namespace musik::core::sdk;
using namespace std::chrono;

static constexpr size_t kDefaultCacheSize = 50;
static constexpr int64_t kCacheWindowTimeoutMs = 150LL;
Expand Down Expand Up @@ -218,7 +221,9 @@ int TrackList::IndexOf(int64_t id) const {
}

void TrackList::Shuffle() {
std::random_shuffle(this->ids.begin(), this->ids.end());
auto seed = static_cast<unsigned>(system_clock::now().time_since_epoch().count());
auto rng = std::default_random_engine(seed);
std::shuffle(this->ids.begin(), this->ids.end(), rng);
}

void TrackList::Clear() noexcept {
Expand Down
12 changes: 12 additions & 0 deletions src/musikcore/musikcore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug-DLL|Win32'">
Expand All @@ -282,6 +283,7 @@
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<AdditionalDependencies>libcurl.lib;libssl-1_1.lib;libcrypto-1_1.lib;%(AdditionalDependencies)</AdditionalDependencies>
Expand All @@ -306,6 +308,7 @@
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand All @@ -325,6 +328,7 @@
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug-DLL|x64'">
Expand All @@ -344,6 +348,7 @@
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<AdditionalDependencies>libcurl.lib;libssl-1_1-x64.lib;libcrypto-1_1-x64.lib;%(AdditionalDependencies)</AdditionalDependencies>
Expand All @@ -367,6 +372,7 @@
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand All @@ -388,6 +394,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release-DLL|Win32'">
Expand All @@ -409,6 +416,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<AdditionalDependencies>libcurl.lib;libssl-1_1.lib;libcrypto-1_1.lib;%(AdditionalDependencies)</AdditionalDependencies>
Expand All @@ -434,6 +442,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
Expand All @@ -455,6 +464,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release-DLL|x64'">
Expand All @@ -476,6 +486,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<AdditionalDependencies>libcurl.lib;libssl-1_1-x64.lib;libcrypto-1_1-x64.lib;%(AdditionalDependencies)</AdditionalDependencies>
Expand All @@ -501,6 +512,7 @@
<ExceptionHandling>Sync</ExceptionHandling>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
Expand Down
Loading

0 comments on commit 90a92c8

Please sign in to comment.