Commit ed16789d authored by Kenneth Leiter's avatar Kenneth Leiter

Replace boost::shared_ptr with std::shared_ptr

Require CMake 3.1 for their c++11 detection support.
Minor fixes to testing harnesses and some missing includes.
parent 851768ca
......@@ -84,8 +84,7 @@ MACRO(ADD_TEST_C executable)
ADD_TEST(C${is_core}_${executable}${dup} ${CMAKE_COMMAND}
-D "EXECUTABLE=${executable}${dup}"
-D "ARGUMENTS=${arguments}"
-D "LDPATH=${c_ldpath}"
-D "PATH=${c_path}"
-D "PATH=${c_path}"
-D "SEPARATOR=${sep}"
-P "${c_binary_dir}/TestDriverC.cmake"
)
......
......@@ -87,8 +87,7 @@ MACRO(ADD_TEST_CXX executable)
SET_CORE("${cxx_binary_dir}")
ADD_TEST(Cxx${is_core}_${executable}${dup} ${CMAKE_COMMAND}
-D "EXECUTABLE=${executable}${dup}"
-D "ARGUMENTS=${arguments}"
-D "LDPATH=${cxx_ldpath}"
-D "ARGUMENTS=${arguments}"
-D "PATH=${cxx_path}"
-D "SEPARATOR=${sep}"
-P "${cxx_binary_dir}/TestDriverCxx.cmake"
......
project(Xdmf)
cmake_minimum_required(VERSION 2.8.5)
cmake_minimum_required(VERSION 3.1)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#Needed to build DSM because relative paths are used to add its libraries
if (POLICY CMP0015)
......
......@@ -266,7 +266,7 @@ XdmfCurvilinearGrid::copyGrid(shared_ptr<XdmfGrid> sourceGrid)
shared_ptr<XdmfArray>
XdmfCurvilinearGrid::getDimensions()
{
return boost::const_pointer_cast<XdmfArray>
return const_pointer_cast<XdmfArray>
(static_cast<const XdmfCurvilinearGrid &>(*this).getDimensions());
}
......@@ -279,7 +279,7 @@ XdmfCurvilinearGrid::getDimensions() const
shared_ptr<XdmfGeometry>
XdmfCurvilinearGrid::getGeometry()
{
return boost::const_pointer_cast<XdmfGeometry>
return const_pointer_cast<XdmfGeometry>
(static_cast<const XdmfGrid &>(*this).getGeometry());
}
......
......@@ -55,7 +55,7 @@ XdmfGraph::getItemTag() const
shared_ptr<XdmfTime>
XdmfGraph::getTime()
{
return boost::const_pointer_cast<XdmfTime>
return const_pointer_cast<XdmfTime>
(static_cast<const XdmfGraph &>(*this).getTime());
}
......
......@@ -126,7 +126,7 @@ XdmfGrid::getName() const
shared_ptr<XdmfTime>
XdmfGrid::getTime()
{
return boost::const_pointer_cast<XdmfTime>
return const_pointer_cast<XdmfTime>
(static_cast<const XdmfGrid &>(*this).getTime());
}
......
......@@ -321,9 +321,8 @@ XdmfRectilinearGrid::copyGrid(shared_ptr<XdmfGrid> sourceGrid)
shared_ptr<XdmfArray>
XdmfRectilinearGrid::getCoordinates(const unsigned int axisIndex)
{
return boost::const_pointer_cast<XdmfArray>
(static_cast<const XdmfRectilinearGrid &>
(*this).getCoordinates(axisIndex));
return const_pointer_cast<XdmfArray>(static_cast<const XdmfRectilinearGrid &>
(*this).getCoordinates(axisIndex));
}
shared_ptr<const XdmfArray>
......@@ -350,7 +349,7 @@ XdmfRectilinearGrid::getCoordinates() const
shared_ptr<XdmfArray>
XdmfRectilinearGrid::getDimensions()
{
return boost::const_pointer_cast<XdmfArray>
return const_pointer_cast<XdmfArray>
(static_cast<const XdmfRectilinearGrid &>(*this).getDimensions());
}
......
......@@ -361,7 +361,7 @@ XdmfRegularGrid::copyGrid(shared_ptr<XdmfGrid> sourceGrid)
shared_ptr<XdmfArray>
XdmfRegularGrid::getBrickSize()
{
return boost::const_pointer_cast<XdmfArray>
return const_pointer_cast<XdmfArray>
(static_cast<const XdmfRegularGrid &>(*this).getBrickSize());
}
......@@ -374,7 +374,7 @@ XdmfRegularGrid::getBrickSize() const
shared_ptr<XdmfArray>
XdmfRegularGrid::getDimensions()
{
return boost::const_pointer_cast<XdmfArray>
return const_pointer_cast<XdmfArray>
(static_cast<const XdmfRegularGrid &>(*this).getDimensions());
}
......@@ -387,7 +387,7 @@ XdmfRegularGrid::getDimensions() const
shared_ptr<XdmfArray>
XdmfRegularGrid::getOrigin()
{
return boost::const_pointer_cast<XdmfArray>
return const_pointer_cast<XdmfArray>
(static_cast<const XdmfRegularGrid &>(*this).getOrigin());
}
......
......@@ -225,7 +225,7 @@ XdmfUnstructuredGrid::copyGrid(shared_ptr<XdmfGrid> sourceGrid)
shared_ptr<XdmfGeometry>
XdmfUnstructuredGrid::getGeometry()
{
return boost::const_pointer_cast<XdmfGeometry>
return const_pointer_cast<XdmfGeometry>
(static_cast<const XdmfGrid &>(*this).getGeometry());
}
......@@ -238,7 +238,7 @@ XdmfUnstructuredGrid::getItemTag() const
shared_ptr<XdmfTopology>
XdmfUnstructuredGrid::getTopology()
{
return boost::const_pointer_cast<XdmfTopology>
return const_pointer_cast<XdmfTopology>
(static_cast<const XdmfGrid &>(*this).getTopology());
}
......
......@@ -742,7 +742,7 @@ XdmfArray::getValuesString() const
shared_ptr<XdmfHeavyDataController>
XdmfArray::getHeavyDataController()
{
return boost::const_pointer_cast<XdmfHeavyDataController>
return const_pointer_cast<XdmfHeavyDataController>
(static_cast<const XdmfArray &>(*this).getHeavyDataController(0));
}
......
......@@ -204,7 +204,7 @@ public :
shared_ptr<ChildClass> \
ParentClass::get##ChildName(const unsigned int index) \
{ \
return boost::const_pointer_cast<ChildClass> \
return const_pointer_cast<ChildClass> \
(static_cast<const ParentClass &>(*this).get##ChildName(index)); \
} \
\
......@@ -220,7 +220,7 @@ public :
shared_ptr<ChildClass> \
ParentClass::get##ChildName(const std::string & SearchName) \
{ \
return boost::const_pointer_cast<ChildClass> \
return const_pointer_cast<ChildClass> \
(static_cast<const ParentClass &>(*this).get##ChildName(SearchName)); \
} \
\
......
......@@ -26,16 +26,22 @@
#ifdef __cplusplus
#include <memory>
#include "XdmfCoreConfig.hpp"
#include <boost/shared_ptr.hpp>
//#include <boost/shared_ptr.hpp>
using std::shared_ptr;
using std::const_pointer_cast;
using boost::shared_ptr;
//using boost::shared_ptr;
//using boost::const_pointer_cast;
#ifdef HAVE_BOOST_SHARED_DYNAMIC_CAST
//#ifdef HAVE_BOOST_SHARED_DYNAMIC_CAST
using boost::shared_dynamic_cast;
//using boost::shared_dynamic_cast;
#else
//#else
template <typename T, typename U>
shared_ptr<T> shared_dynamic_cast(shared_ptr<U> const & r)
......@@ -45,16 +51,7 @@ shared_ptr<T> shared_dynamic_cast(shared_ptr<U> const & r)
return p? shared_ptr<T>( r, p ): shared_ptr<T>();
}
#endif /* HAVE_BOOST_SHARED_DYNAMIC_CAST */
// Used by C wrappers to prevent shared pointers from prematurely deleting objects
// Normally this would be completely against the point of shared pointers,
// but the C wrapping requires that objects be seperated from the shared pointers.
struct XdmfNullDeleter
{
template<typename T>
void operator()(T*) {}
};
//#endif /* HAVE_BOOST_SHARED_DYNAMIC_CAST */
#endif
......
......@@ -244,7 +244,7 @@ XdmfWriter::~XdmfWriter()
shared_ptr<XdmfHeavyDataWriter>
XdmfWriter::getHeavyDataWriter()
{
return boost::const_pointer_cast<XdmfHeavyDataWriter>
return const_pointer_cast<XdmfHeavyDataWriter>
(static_cast<const XdmfWriter &>(*this).getHeavyDataWriter());
}
......
#include <cassert>
#include <sstream>
#include <iostream>
#include "XdmfArrayType.hpp"
......@@ -15,9 +16,11 @@ int main(int, char **)
std::vector<unsigned int>(1, 10),
std::vector<unsigned int>(1, 10));
std::cout << controller->getDataSetPath() << " ?= " << "/foo/data1" << std::endl;
std::cout << controller->getDataSetPath() << " ?= " << "/foo/data1"
<< std::endl;
std::cout << controller->getSize() << " ?= " << 10 << std::endl;
std::cout << controller->getType() << " ?= " << XdmfArrayType::Int8() << std::endl;
std::cout << controller->getType() << " ?= " << XdmfArrayType::Int8()
<< std::endl;
assert(controller->getDataSetPath().compare("/foo/data1") == 0);
assert(controller->getSize() == 10);
......
#include "XdmfTime.hpp"
#include <cassert>
#include <iostream>
#include "XdmfTime.hpp"
int main(int, char **)
{
shared_ptr<XdmfTime> time = XdmfTime::New();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment