// $ g++ --std=c++11 -Wall -Wextra focemove.cpp
// $ ./a.out
// Yes using rvalue, move semantics
// Yes using rvalue, move semantics
// Oh no you forgot std::move somewhere. Deep copy occurs
//
// After delete unwanted ctor
// focemove.cpp: In function ‘void helper(std::vector< int >&&)’:
// focemove.cpp:44:20: error: use of deleted function ‘TestClass::TestClass(std::vector< int >&)’
// focemove.cpp:28:3: error: declared here
//
// testet with 4.7.4 - 5.2.1
#include < vector >
#include < iostream >
#include < utility >
using namespace std;
// this class store biiiig data in a std::vector.
// If we initialize it with a const reference ctor a deep copy occurs.
// To prevent this, either dont proice a const reference ctor or better:
// forbid it at all.
class TestClass {
public:
TestClass(vector< int > & other)
: vec(other)
{
cout << "Oh no you forgot std::move somewhere. Deep copy occurs\n";
}
// do we have to delete a const and non-const version here??
// TestClass(const vector< int > & other) = delete;
// TestClass(vector< int > & other) = delete;
TestClass(vector< int > && other)
: vec(other)
{
cout << "Yes using rvalue, move semantics\n";
}
private:
vector< int > vec;
};
void helper(vector< in t> && other) {
// is other a rvalue or lvalue? It depends on the caller
// here we forgot to use std::move(other)
// other is a named rvalue and thus no move semantics are used
TestClass a(other);
// comment in this to test after fix TestClass constructor
// TestClass a(move(other));
}
int main() {
// this works all fine. All use move semantics
TestClass(vector< int >()); // using temporaries, unnamed variables
vector< int > other;
TestClass(std::move(other)); // named variable other is converted to an unnamed with std::move
// this call is okay
helper(std::move(other));
// this line triggers a error
// cannot bind ‘std::vector< int >’ lvalue to ‘std::vector< int >&&’
// helper(other);
return 0;
}
30.09.2015
c++11 move semantics - force it
Comments Off on c++11 move semantics - force it
21.09.2015
Depends: but it is not going to be installed - resolve apt dependencies
Edit file
/var/lib/dpkg/status
Search for packet with dependency problem. Edit dependency list and fix version numbering to a version, that is installed.
Comments Off on Depends: but it is not going to be installed - resolve apt dependencies
ganglia lm-sensors
thomas@H8QGL:~$ cat gmetric-cpu-temp
#!/bin/bash
# this script read the core(s) temperature using lm sensors then calculate the average
# and send it to the ganglia using gmetric
# assumes that the lines reported by lm sensors are formated like this
# Core 0: +46.0 C (high = +80.0 C, crit = +100.0 C)
SENSORS=/usr/bin/sensors
GMETRIC=/usr/bin/gmetric
#sensors
let count=0
sum=0.0
for temp in $($SENSORS | grep temp | grep -e '+.*C' | cut -f 2 -d '+' | sed 's/°/ /g' | cut -f 1 -d ' '); do
if (($(echo "$temp > 1.0" | bc) ))
then
sum=$(echo $sum+$temp | bc);
# echo $temp, $sum, $count
let count+=1;
fi
done
temp=$(echo "scale=1; $sum/$count" | bc)
#echo $temp
$GMETRIC -t float -n "avg temp" -u "Celcius" -v $temp
Fehlerhaftes Original here: http://computational.engineering.or.id/LM_Sensors#Integrasi_Dengan_Ganglia
In meiner Version wird das Grad-Celsius Zeichen rausgefiltert.
Es werden nur echte Temperaturen verrechnet, keine min und max Werte.
Falsche Temperaturen wie z.b. 0.8C werden ignoriert nud erst ab 1Grad verrechnet.
thomas@H8QGL:~$ cat /etc/cron.d/sensors
* * * * * root /usr/local/bin/gmetric-cpu-temp
Comments Off on ganglia lm-sensors