minlevel = new_minlevel;
for (unsigned int i=0; i<new_maxlevel-new_minlevel+1; ++i)
- objects.push_back(std::shared_ptr<Object> (new Object));
+ objects.push_back(std::make_shared<Object> ());
}
TBBPartitioner()
#ifdef DEAL_II_WITH_THREADS
:
- my_partitioner(new tbb::affinity_partitioner()),
+ my_partitioner(std::make_shared<tbb::affinity_partitioner>()),
in_use(false)
#endif
{}
{
dealii::Threads::Mutex::ScopedLock lock(mutex);
if (in_use)
- return std::shared_ptr<tbb::affinity_partitioner>(new tbb::affinity_partitioner());
+ return std::make_shared<tbb::affinity_partitioner>();
in_use = true;
return my_partitioner;
* object. Every nodes in the property tree corresponding to a parameter
* stores an index into this array.
*/
- std::vector<std::shared_ptr<const Patterns::PatternBase> > patterns;
+ std::vector<std::unique_ptr<const Patterns::PatternBase> > patterns;
/**
* A list of actions that are associated with parameters. These
*
* static void declare_parameters (ParameterHandler &prm);
* private:
- * std::shared_ptr<Problem> p;
+ * std::unique_ptr<Problem> p;
* };
*
*
*
* void HelperClass::create_new (const unsigned int run_no)
* {
- * p.reset(new Problem());
+ * p = std_cxx14::make_unique<Problem>());
* }
*
*
patterns.clear ();
for (unsigned int j=0; j<descriptions.size(); ++j)
- patterns.push_back (std::shared_ptr<const Patterns::PatternBase>(Patterns::pattern_factory(descriptions[j])));
+ patterns.push_back (Patterns::pattern_factory(descriptions[j]));
}
* polynomial, we keep one pointer to the list of coefficients; we do so
* rather than keeping a vector of vectors in order to simplify
* programming multithread-safe. In order to avoid memory leak, we use a
- * shared_ptr in order to correctly free the memory of the vectors when
+ * unique_ptr in order to correctly free the memory of the vectors when
* the global destructor is called.
*/
- static std::vector<std::shared_ptr<const std::vector<double> > > recursive_coefficients;
+ static std::vector<std::unique_ptr<const std::vector<double> > > recursive_coefficients;
};
void start (const std::function<RT ()> &function)
{
thread_is_active = true;
- ret_val.reset(new return_value<RT>());
+ ret_val = std::make_shared<return_value<RT>>();
thread = std::thread (thread_entry_point, function, ret_val);
}
*/
void start (const std::function<RT ()> &function)
{
- ret_val.reset(new return_value<RT>());
+ ret_val = std::make_shared<return_value<RT>>();
call (function, *ret_val);
}
{
// create a task descriptor and tell it to queue itself up with
// the scheduling system
- task_descriptor.reset (new internal::TaskDescriptor<RT>(function_object));
+ task_descriptor = std::make_shared<internal::TaskDescriptor<RT>>(function_object);
task_descriptor->queue_task ();
}
// there can only be one access at a time
if (outstreams.get().get() == nullptr)
{
- outstreams.get().reset (new std::ostringstream);
+ outstreams.get() = std::make_shared<std::ostringstream>();
outstreams.get()->setf(std::ios::showpoint | std::ios::left);
}
read_xml_recursively (const boost::property_tree::ptree &source,
const std::string ¤t_path,
const char path_separator,
- const std::vector<std::shared_ptr<const Patterns::PatternBase> > &
+ const std::vector<std::unique_ptr<const Patterns::PatternBase> > &
patterns,
boost::property_tree::ptree &destination)
{
void ParameterHandler::clear ()
{
- entries.reset (new boost::property_tree::ptree());
+ entries = std_cxx14::make_unique<boost::property_tree::ptree> ();
}
is.ignore(strlen(description_init) + strlen(" range "));
if (!(is >> lower_bound))
- return std::unique_ptr<Integer>(new Integer());
+ return std_cxx14::make_unique<Integer>();
is.ignore(strlen("..."));
if (!(is >> upper_bound))
- return std::unique_ptr<Integer>(new Integer());
+ return std_cxx14::make_unique<Integer>();
- return std::unique_ptr<Integer>(new Integer(lower_bound, upper_bound));
+ return std_cxx14::make_unique<Integer>(lower_bound, upper_bound);
}
else
- return std::unique_ptr<Integer>(new Integer());
+ return std_cxx14::make_unique<Integer>();
}
else
return std::unique_ptr<Integer>();
std::string temp = description.substr(description_init_str.size());
if (temp == "]")
- return std::unique_ptr<Double>(new Double(1.0, -1.0)); // return an invalid range
+ return std_cxx14::make_unique<Double>(1.0, -1.0); // return an invalid range
if (temp.find("...") != std::string::npos)
temp.replace(temp.find("..."), 3, " ");
if (is.fail())
upper_bound = max_double_value;
- return std::unique_ptr<Double>(new Double(lower_bound, upper_bound));
+ return std_cxx14::make_unique<Double>(lower_bound, upper_bound);
}
sequence.erase(0, std::strlen(description_init) + 1);
sequence.erase(sequence.length()-2, 2);
- return std::unique_ptr<Selection>(new Selection(sequence));
+ return std_cxx14::make_unique<Selection>(sequence);
}
else
return std::unique_ptr<Selection>();
{
if (description.compare(0, std::strlen(description_init), description_init) == 0)
{
- int min_elements, max_elements;
+ unsigned int min_elements = 0, max_elements = 0;
std::istringstream is(description);
is.ignore(strlen(description_init) + strlen(" of <"));
std::string str;
std::getline(is, str, '>');
- std::shared_ptr<PatternBase> base_pattern (pattern_factory(str));
+ std::unique_ptr<PatternBase> base_pattern (pattern_factory(str));
is.ignore(strlen(" of length "));
if (!(is >> min_elements))
- return std::unique_ptr<List>(new List(*base_pattern));
+ return std_cxx14::make_unique<List>(*base_pattern);
is.ignore(strlen("..."));
if (!(is >> max_elements))
- return std::unique_ptr<List>(new List(*base_pattern, min_elements));
+ return std_cxx14::make_unique<List>(*base_pattern, min_elements);
is.ignore(strlen(" (inclusive) separated by <"));
std::string separator;
- if (is)
+ if (!is.eof())
std::getline(is, separator, '>');
else
separator = ",";
- return std::unique_ptr<List>(new List(*base_pattern, min_elements, max_elements, separator));
+ return std_cxx14::make_unique<List>(*base_pattern, min_elements, max_elements, separator);
}
else
return std::unique_ptr<List>();
{
if (description.compare(0, std::strlen(description_init), description_init) == 0)
{
- int min_elements, max_elements;
+ unsigned int min_elements = 0, max_elements = 0;
std::istringstream is(description);
is.ignore(strlen(description_init) + strlen(" of <"));
std::string value;
std::getline(is, value, '>');
- std::shared_ptr<PatternBase> key_pattern (pattern_factory(key));
- std::shared_ptr<PatternBase> value_pattern (pattern_factory(value));
+ std::unique_ptr<PatternBase> key_pattern (pattern_factory(key));
+ std::unique_ptr<PatternBase> value_pattern (pattern_factory(value));
is.ignore(strlen(" of length "));
if (!(is >> min_elements))
- return std::unique_ptr<Map>(new Map(*key_pattern, *value_pattern));
+ return std_cxx14::make_unique<Map>(*key_pattern, *value_pattern);
is.ignore(strlen("..."));
if (!(is >> max_elements))
- return std::unique_ptr<Map>(new Map(*key_pattern, *value_pattern, min_elements));
+ return std_cxx14::make_unique<Map>(*key_pattern, *value_pattern, min_elements);
is.ignore(strlen(" (inclusive) separated by <"));
std::string separator;
- if (is)
+ if (!is.eof())
std::getline(is, separator, '>');
else
separator = ",";
- return std::unique_ptr<Map>(new Map(*key_pattern, *value_pattern,
- min_elements, max_elements,
- separator, key_value_separator));
+ return std_cxx14::make_unique<Map>(*key_pattern, *value_pattern,
+ min_elements, max_elements,
+ separator, key_value_separator);
}
else
return std::unique_ptr<Map>();
is.ignore(strlen(" separated by <"));
std::string separator;
- if (is)
+ if (!is.eof())
std::getline(is, separator, '>');
else
separator = ":";
- return std::unique_ptr<Tuple>(new Tuple(patterns,separator));
+ return std_cxx14::make_unique<Tuple>(patterns,separator);
}
else
return std::unique_ptr<Tuple>();
sequence.erase(0, std::strlen(description_init) + 1);
sequence.erase(sequence.length()-2, 2);
- return std::unique_ptr<MultipleSelection>(new MultipleSelection(sequence));
+ return std_cxx14::make_unique<MultipleSelection>(sequence);
}
else
return std::unique_ptr<MultipleSelection>();
std::unique_ptr<Bool> Bool::create (const std::string &description)
{
if (description.compare(0, std::strlen(description_init), description_init) == 0)
- return std::unique_ptr<Bool>(new Bool());
+ return std_cxx14::make_unique<Bool>();
else
return std::unique_ptr<Bool>();
}
std::unique_ptr<Anything> Anything::create (const std::string &description)
{
if (description.compare(0, std::strlen(description_init), description_init) == 0)
- return std::unique_ptr<Anything>(new Anything());
+ return std_cxx14::make_unique<Anything>();
else
return std::unique_ptr<Anything>();
}
else
type = output;
- return std::unique_ptr<FileName>(new FileName(type));
+ return std_cxx14::make_unique<FileName>(type);
}
else
return std::unique_ptr<FileName>();
std::unique_ptr<DirectoryName> DirectoryName::create (const std::string &description)
{
if (description.compare(0, std::strlen(description_init), description_init) == 0)
- return std::unique_ptr<DirectoryName>(new DirectoryName());
+ return std_cxx14::make_unique<DirectoryName>();
else
return std::unique_ptr<DirectoryName>();
}
//
// ---------------------------------------------------------------------
-#include <deal.II/base/polynomial.h>
-#include <deal.II/base/point.h>
#include <deal.II/base/exceptions.h>
-#include <deal.II/base/thread_management.h>
+#include <deal.II/base/point.h>
+#include <deal.II/base/polynomial.h>
#include <deal.II/base/quadrature_lib.h>
+#include <deal.II/base/std_cxx14/memory.h>
+#include <deal.II/base/thread_management.h>
#include <deal.II/lac/full_matrix.h>
#include <deal.II/lac/lapack_full_matrix.h>
-
#include <cmath>
#include <algorithm>
#include <limits>
// need to transform p into standard form as
// well if necessary. copy the polynomial to
// do this
- std::shared_ptr<Polynomial<number> > q_data;
+ std::unique_ptr<Polynomial<number> > q_data;
const Polynomial<number> *q = nullptr;
if (p.in_lagrange_product_form == true)
{
- q_data.reset (new Polynomial<number>(p));
+ q_data = std_cxx14::make_unique<Polynomial<number>>(p);
q_data->transform_into_standard_form();
q = q_data.get();
}
// need to transform p into standard form as
// well if necessary. copy the polynomial to
// do this
- std::shared_ptr<Polynomial<number> > q_data;
+ std::unique_ptr<Polynomial<number> > q_data;
const Polynomial<number> *q = nullptr;
if (p.in_lagrange_product_form == true)
{
- q_data.reset (new Polynomial<number>(p));
+ q_data = std_cxx14::make_unique<Polynomial<number>>(p);
q_data->transform_into_standard_form();
q = q_data.get();
}
// need to transform p into standard form as
// well if necessary. copy the polynomial to
// do this
- std::shared_ptr<Polynomial<number> > q_data;
+ std::unique_ptr<Polynomial<number> > q_data;
const Polynomial<number> *q = nullptr;
if (p.in_lagrange_product_form == true)
{
- q_data.reset (new Polynomial<number>(p));
+ q_data = std_cxx14::make_unique<Polynomial<number>>(p);
q_data->transform_into_standard_form();
q = q_data.get();
}
if (degree() == 0)
return Monomial<number>(0, 0.);
- std::shared_ptr<Polynomial<number> > q_data;
+ std::unique_ptr<Polynomial<number> > q_data;
const Polynomial<number> *q = nullptr;
if (in_lagrange_product_form == true)
{
- q_data.reset (new Polynomial<number>(*this));
+ q_data = std_cxx14::make_unique<Polynomial<number>>(*this);
q_data->transform_into_standard_form();
q = q_data.get();
}
{
// no simple form possible for Lagrange
// polynomial on product form
- std::shared_ptr<Polynomial<number> > q_data;
+ std::unique_ptr<Polynomial<number> > q_data;
const Polynomial<number> *q = nullptr;
if (in_lagrange_product_form == true)
{
- q_data.reset (new Polynomial<number>(*this));
+ q_data = std_cxx14::make_unique<Polynomial<number>>(*this);
q_data->transform_into_standard_form();
q = q_data.get();
}
// Reserve space for polynomials up to degree 19. Should be sufficient
// for the start.
- std::vector<std::shared_ptr<const std::vector<double> > >
+ std::vector<std::unique_ptr<const std::vector<double> > >
Hierarchical::recursive_coefficients(20);
// now make these arrays
// const
recursive_coefficients[0] =
- std::shared_ptr<const std::vector<double> >(c0);
+ std::unique_ptr<const std::vector<double> >(c0);
recursive_coefficients[1] =
- std::shared_ptr<const std::vector<double> >(c1);
+ std::unique_ptr<const std::vector<double> >(c1);
}
else if (k==2)
{
(*c2)[2] = 4.*a;
recursive_coefficients[2] =
- std::shared_ptr<const std::vector<double> >(c2);
+ std::unique_ptr<const std::vector<double> >(c2);
}
else
{
// const pointer in the
// coefficients array
recursive_coefficients[k] =
- std::shared_ptr<const std::vector<double> >(ck);
+ std::unique_ptr<const std::vector<double> >(ck);
};
};
}
if (is_tensor_product_flag)
{
- tensor_basis.reset(new std::array<Quadrature<1>, dim>());
+ tensor_basis = std_cxx14::make_unique<std::array<Quadrature<1>, dim>> ();
for (unsigned int i=0; i<dim-1; ++i)
(*tensor_basis)[i] = q1.get_tensor_basis()[i];
(*tensor_basis)[dim-1] = q2;
++k;
}
- tensor_basis.reset (new std::array<Quadrature<1>, dim>());
+ tensor_basis = std_cxx14::make_unique<std::array<Quadrature<1>, dim>> ();
for (unsigned int i=0; i<dim; ++i)
(*tensor_basis)[i] = q;
}