mirror of
https://github.com/OPM/ResInsight.git
synced 2024-12-28 18:01:08 -06:00
System: Enable and use c++20
Enable c++20 in top level cmake. Keep c++17 for GrpcInterface, as the protoc tool does not work with c++20. Several code adjustments to fix compiler issues.
This commit is contained in:
parent
712bad97bd
commit
abc9e82ff5
@ -187,9 +187,19 @@ std::vector<std::string> RiaStdStringTools::splitString( const std::string& s, c
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::string RiaStdStringTools::joinStrings( const std::vector<std::string>& s, char delimiter )
|
||||
{
|
||||
std::string delimiterString( 1, delimiter );
|
||||
std::string joinedString;
|
||||
|
||||
return join( s.begin(), s.end(), delimiterString );
|
||||
for ( const auto& str : s )
|
||||
{
|
||||
if ( !joinedString.empty() )
|
||||
{
|
||||
joinedString += delimiter;
|
||||
}
|
||||
|
||||
joinedString += str;
|
||||
}
|
||||
|
||||
return joinedString;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -362,6 +362,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
-Wno-braced-scalar-init
|
||||
-Wno-tautological-constant-out-of-range-compare
|
||||
-Wno-undefined-var-template
|
||||
-Wno-ambiguous-reversed-operator
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@ -89,6 +89,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
-Wno-braced-scalar-init
|
||||
-Wno-tautological-constant-out-of-range-compare
|
||||
-Wno-undefined-var-template
|
||||
-Wno-ambiguous-reversed-operator
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@ -79,7 +79,7 @@ void RicCreatePlotFromTemplateByShortcutFeature::setupActionLook( QAction* actio
|
||||
actionToSetup->setText( "Create Plot from Last Used Template" );
|
||||
actionToSetup->setIcon( QIcon( ":/SummaryTemplate16x16.png" ) );
|
||||
|
||||
QKeySequence keySeq( Qt::CTRL + Qt::Key_T );
|
||||
QKeySequence keySeq( Qt::CTRL, Qt::Key_T );
|
||||
|
||||
applyShortcutWithHintToAction( actionToSetup, keySeq );
|
||||
}
|
||||
|
@ -17,6 +17,10 @@
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// These includes need to be first to avoid compile errors when compiling with MSVC using c++20
|
||||
#include <algorithm>
|
||||
#include <ostream>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// Get rid of warnings from compilation of ODB API
|
||||
#pragma warning( push )
|
||||
@ -38,7 +42,9 @@
|
||||
#include "RigFemTypes.h"
|
||||
|
||||
#include "cafProgressInfo.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <map>
|
||||
|
@ -244,7 +244,7 @@ QString RimWellRftPlot::associatedSimWellName() const
|
||||
void RimWellRftPlot::applyInitialSelections()
|
||||
{
|
||||
std::map<QString, QStringList> wellSources = findWellSources();
|
||||
if ( m_wellPathNameOrSimWellName == "None" && !wellSources.empty() )
|
||||
if ( m_wellPathNameOrSimWellName() == "None" && !wellSources.empty() )
|
||||
{
|
||||
m_wellPathNameOrSimWellName = wellSources.begin()->first;
|
||||
}
|
||||
|
@ -553,7 +553,7 @@ QString RimGeoMechResultDefinition::composeFieldCompString( const QString& resul
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechResultDefinition::initAfterRead()
|
||||
{
|
||||
if ( m_resultComponentName == "STM" || m_resultComponentName == "SEM" ) m_resultComponentName = "SM";
|
||||
if ( m_resultComponentName() == "STM" || m_resultComponentName() == "SEM" ) m_resultComponentName = "SM";
|
||||
|
||||
m_resultPositionTypeUiField = m_resultPositionType;
|
||||
m_resultVariableUiField = composeFieldCompString( m_resultFieldName(), m_resultComponentName() );
|
||||
|
@ -519,7 +519,7 @@ bool RimCellEdgeColors::showTextResult() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimCellEdgeColors::updateIgnoredScalarValue()
|
||||
{
|
||||
if ( m_resultVariable == "MULT" || m_resultVariable == "riMULT" )
|
||||
if ( m_resultVariable() == "MULT" || m_resultVariable() == "riMULT" )
|
||||
{
|
||||
m_ignoredResultScalar = 1.0;
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ void RimEclipseCellColors::initAfterRead()
|
||||
{
|
||||
RimEclipseResultDefinition::initAfterRead();
|
||||
|
||||
if ( this->m_legendConfigPtrField() && this->m_legendConfigPtrField()->resultVariableName == "" )
|
||||
if ( this->m_legendConfigPtrField() && this->m_legendConfigPtrField()->resultVariableName() == "" )
|
||||
{
|
||||
this->m_legendConfigPtrField()->resultVariableName = this->resultVariable();
|
||||
}
|
||||
|
@ -1277,12 +1277,12 @@ void RimEclipseResultDefinition::initAfterRead()
|
||||
assignFlowSolutionFromCase();
|
||||
}
|
||||
|
||||
if ( m_resultVariable == "Formation Allen" )
|
||||
if ( m_resultVariable() == "Formation Allen" )
|
||||
{
|
||||
m_resultVariable = RiaResultNames::formationAllanResultName();
|
||||
m_resultType = RiaDefines::ResultCatType::ALLAN_DIAGRAMS;
|
||||
}
|
||||
else if ( m_resultVariable == "Binary Formation Allen" )
|
||||
else if ( m_resultVariable() == "Binary Formation Allen" )
|
||||
{
|
||||
m_resultVariable = RiaResultNames::formationBinaryAllanResultName();
|
||||
m_resultType = RiaDefines::ResultCatType::ALLAN_DIAGRAMS;
|
||||
|
@ -653,11 +653,11 @@ void RimRegularLegendConfig::setAutomaticRanges( double globalMin, double global
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimRegularLegendConfig::initAfterRead()
|
||||
{
|
||||
if ( resultVariableName == "Binary Formation Allen" )
|
||||
if ( resultVariableName() == "Binary Formation Allen" )
|
||||
{
|
||||
resultVariableName = RiaResultNames::formationBinaryAllanResultName();
|
||||
}
|
||||
else if ( resultVariableName == "Formation Allen" )
|
||||
else if ( resultVariableName() == "Formation Allen" )
|
||||
{
|
||||
resultVariableName = RiaResultNames::formationAllanResultName();
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ void RimSummaryCaseCollection::sortByBinnedVariation( std::vector<RigEnsemblePar
|
||||
return;
|
||||
}
|
||||
|
||||
double delta = ( maxStdDev - minStdDev ) / RigEnsembleParameter::NR_OF_VARIATION_BINS;
|
||||
double delta = ( maxStdDev - minStdDev ) / (float)( RigEnsembleParameter::NR_OF_VARIATION_BINS );
|
||||
|
||||
std::vector<double> bins;
|
||||
bins.push_back( 0.0 );
|
||||
|
@ -111,9 +111,9 @@ void RimFileWellPath::setWellPathIndexInFile( int index )
|
||||
void RimFileWellPath::setSurveyType( QString surveyType )
|
||||
{
|
||||
m_surveyType = surveyType;
|
||||
if ( m_surveyType == "PLAN" )
|
||||
if ( m_surveyType() == "PLAN" )
|
||||
setWellPathColor( cvf::Color3f( 0.999f, 0.333f, 0.0f ) );
|
||||
else if ( m_surveyType == "PROTOTYPE" )
|
||||
else if ( m_surveyType() == "PROTOTYPE" )
|
||||
setWellPathColor( cvf::Color3f( 0.0f, 0.333f, 0.999f ) );
|
||||
}
|
||||
|
||||
|
@ -40,8 +40,7 @@ if(VCPKG_AUTO_INSTALL)
|
||||
set(AUTO_VCPKG_ROOT "${CMAKE_SOURCE_DIR}/ThirdParty/vcpkg")
|
||||
endif()
|
||||
|
||||
# Use CMake to enforce C++17
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
|
@ -526,7 +526,7 @@ TEST( BaseTest, PdmPtrField )
|
||||
|
||||
// Operator ->
|
||||
ihd1->m_ptrField->m_texts = "Hei PtrField";
|
||||
EXPECT_TRUE( ihd1->m_ptrField->m_texts == "Hei PtrField" );
|
||||
EXPECT_TRUE( ihd1->m_ptrField->m_texts() == "Hei PtrField" );
|
||||
|
||||
// Referencing system
|
||||
{
|
||||
|
@ -840,12 +840,12 @@ TEST( BaseTest, PdmObjectGroupCopyOfTypedObjects )
|
||||
std::vector<caf::PdmPointer<SimpleObj>> simpleObjList;
|
||||
og.createCopyByType( &simpleObjList, caf::PdmDefaultObjectFactory::instance() );
|
||||
EXPECT_EQ( size_t( 3 ), simpleObjList.size() );
|
||||
EXPECT_EQ( 1000, simpleObjList[0]->m_position );
|
||||
EXPECT_EQ( 1000, simpleObjList[0]->m_position() );
|
||||
EXPECT_EQ( size_t( 1 ), simpleObjList[0]->m_numbers.v().size() );
|
||||
EXPECT_EQ( 10, simpleObjList[0]->m_numbers.v()[0] );
|
||||
|
||||
EXPECT_EQ( 2000, simpleObjList[1]->m_position );
|
||||
EXPECT_EQ( 3000, simpleObjList[2]->m_position );
|
||||
EXPECT_EQ( 2000, simpleObjList[1]->m_position() );
|
||||
EXPECT_EQ( 3000, simpleObjList[2]->m_position() );
|
||||
|
||||
std::vector<caf::PdmPointer<InheritedDemoObj>> inheritObjList;
|
||||
og.createCopyByType( &inheritObjList, caf::PdmDefaultObjectFactory::instance() );
|
||||
|
@ -21,6 +21,9 @@ if(MSVC)
|
||||
add_definitions(-D_WIN32_WINNT=0x600)
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
|
||||
add_definitions(-D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING)
|
||||
|
||||
find_package(
|
||||
|
Loading…
Reference in New Issue
Block a user