Skip to content
Snippets Groups Projects
Commit 535b4a1b authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

clang-tidy: pass by value and use std::move [modernize-pass-by-value]

parent 7d2047a3
No related branches found
No related tags found
1 merge request!122Linting setup + code updates
......@@ -4,14 +4,20 @@
#include <chrono>
#include <functional>
#include <iostream>
#include <utility>
struct TIMER
{
std::function<void(double)> f;
std::chrono::high_resolution_clock::time_point begin;
TIMER(std::function<void(double)> func = [](double res){std::cout << res << std::endl;})
: f(func), begin(std::chrono::high_resolution_clock::now()) {}
TIMER( std::function< void( double ) > func =
[]( double res )
{
std::cout << res << std::endl;
} )
: f( std::move( func ) ), begin( std::chrono::high_resolution_clock::now() )
{}
~TIMER()
{
......
......@@ -8,6 +8,7 @@
#pragma once
#include <utility>
#include <vector>
#include <sstream>
......@@ -35,8 +36,8 @@ public:
_hasDefaultValue = false;
}
ConfigEntry( const std::string& name, const std::string& description, bool required, const DefaultValueType& defaultValue )
: ConfigEntryBase( name, description, required ), defaultValue( defaultValue )
ConfigEntry( const std::string& name, const std::string& description, bool required, DefaultValueType defaultValue )
: ConfigEntryBase( name, description, required ), defaultValue( std::move( defaultValue ) )
{
_hasDefaultValue = true;
}
......
......@@ -9,6 +9,7 @@
#pragma once
#include <string>
#include <utility>
namespace TNL {
namespace Config {
......@@ -25,8 +26,8 @@ protected:
bool _hasDefaultValue;
public:
ConfigEntryBase( const std::string& name, const std::string& description, bool required )
: name( name ), description( description ), required( required ), _hasDefaultValue( false )
ConfigEntryBase( std::string name, std::string description, bool required )
: name( std::move( name ) ), description( std::move( description ) ), required( required ), _hasDefaultValue( false )
{}
const std::string&
......
......@@ -39,7 +39,7 @@ public:
*
* @param fileNameBase File name base.
*/
FileName( const String& fileNameBase );
FileName( String fileNameBase );
/**
* \brief Constructor with file name base and file name extension.
......@@ -49,7 +49,7 @@ public:
* @param fileNameBase File name base.
* @param extension File name extension.
*/
FileName( const String& fileNameBase, const String& extension );
FileName( String fileNameBase, String extension );
/**
* \brief Sets the file name base.
......
......@@ -8,6 +8,7 @@
#include <sstream>
#include <iomanip>
#include <utility>
#include <TNL/FileName.h>
#include <TNL/String.h>
......@@ -17,11 +18,10 @@
namespace TNL {
inline FileName::FileName( const String& fileNameBase ) : fileNameBase( fileNameBase )
{}
inline FileName::FileName( String fileNameBase ) : fileNameBase( std::move( fileNameBase ) ) {}
inline FileName::FileName( const String& fileNameBase, const String& extension )
: fileNameBase( fileNameBase ), extension( extension )
inline FileName::FileName( String fileNameBase, String extension )
: fileNameBase( std::move( fileNameBase ) ), extension( std::move( extension ) )
{}
inline void
......
......@@ -86,7 +86,7 @@ public:
* @param values is a vector view with matrix elements values.
*/
__cuda_callable__
MatrixView( IndexType rows, IndexType columns, const ValuesView& values );
MatrixView( IndexType rows, IndexType columns, ValuesView values );
/**
* @brief Shallow copy constructor.
......
......@@ -12,6 +12,8 @@
#include <TNL/Cuda/MemoryHelpers.h>
#include <TNL/Cuda/SharedMemory.h>
#include <utility>
namespace TNL {
namespace Matrices {
......@@ -21,8 +23,8 @@ MatrixView< Real, Device, Index >::MatrixView() : rows( 0 ), columns( 0 ) {}
template< typename Real, typename Device, typename Index >
__cuda_callable__
MatrixView< Real, Device, Index >::MatrixView( const IndexType rows_, const IndexType columns_, const ValuesView& values_ )
: rows( rows_ ), columns( columns_ ), values( values_ )
MatrixView< Real, Device, Index >::MatrixView( const IndexType rows_, const IndexType columns_, ValuesView values_ )
: rows( rows_ ), columns( columns_ ), values( std::move( values_ ) )
{}
template< typename Real, typename Device, typename Index >
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment