-
+46
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
//Сом ненужный щит
#include <iostream>
using namespace std;
#include <string>
#include <iostream>
struct Tracer {
Tracer(void)
:m_name("(none)")
{
std::cout << "[" << m_name << "] " << __PRETTY_FUNCTION__ << std::endl;
}
Tracer(const std::string & name)
:m_name(name)
{
std::cout << "[" << m_name << "] " << __PRETTY_FUNCTION__ << std::endl;
}
Tracer(const Tracer & other)
:m_name(other.m_name)
{
std::cout << "[" << m_name << "] " << __PRETTY_FUNCTION__ << std::endl;
}
Tracer(const Tracer && other)
:m_name(other.m_name)
{
std::cout << "[" << m_name << "] " << __PRETTY_FUNCTION__ << std::endl;
}
Tracer & operator=(const Tracer & other) {
m_name = other.m_name;
std::cout << "[" << m_name << "] " << __PRETTY_FUNCTION__ << std::endl;
return *this;
}
Tracer & operator=(const Tracer && other) {
m_name = other.m_name;
std::cout << "[" << m_name << "] " << __PRETTY_FUNCTION__ << std::endl;
return *this;
}
~Tracer() {
std::cout << "[" << m_name << "] " << __PRETTY_FUNCTION__ << std::endl;
m_name="You looser!";
}
std::string m_name;
};
//Тот щит, ради чего всё затевалось
template<class T> const T& Min(const T &x, const T &y) { return (x.m_name < y.m_name) ? x : y; }
int main() {
const Tracer& mr = Min(Tracer("a"), Tracer("b"));
cout<<"Some work with mr: "<<mr.m_name<<endl;
return 0;
}
[b] Tracer::Tracer(const string&)
[a] Tracer::Tracer(const string&)
[a] Tracer::~Tracer()
[b] Tracer::~Tracer()
Some work with mr:
Этож сколько я коммитов сделал с возвратом константной ссылки на константный параметр.
LispGovno,
04 Февраля 2014
-
+36
- 1
- 2
- 3
t = Min(::std::cref(x), ::std::cref(y));
//или в зависимости от ситуации
t = Min(::std::move(x), ::std::move(y));
Абстракционизм или Кубизм?
LispGovno,
04 Февраля 2014
-
+139
Creates the directory named by this abstract pathname.
Returns: true if and only if the directory was created; false otherwise
P.S. В java.nio сделали адекватную функцию, еще один гвоздь в крышку гроба шестерки.
bormand,
04 Февраля 2014
-
+70
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
public class ImportException extends Exception {
public static final int NOT_CRITICAL = 1;
public static final int CRITICAL = 2;
private int criticality = NOT_CRITICAL;
public ImportException(String message) {
this.message = message;
}
/**
* С критичностью
* @param message
* @param criticality
*/
public ImportException(String message, int criticality) {
this.message = message;
this.criticality = criticality;
}
public int getCriticality() {
return criticality;
}
public void setCriticality(int criticality) {
this.criticality = criticality;
}
}
изобретение типа bool
evg_ever,
04 Февраля 2014
-
+64
- 1
- 2
- 3
// Полный импорт
private void fullImport(Collection<Entity> entities, File unzippedDir)
throws IOException {
спасибо за подсказку
evg_ever,
04 Февраля 2014
-
+67
- 1
- 2
- 3
File unzippedDir = File.createTempFile("po.", null);
unzippedDir.delete();
unzippedDir = new File(unzippedDir.getAbsoluteFile() + ".dir");
ну да, а посмотреть сигнатуру метода, который вызываем, не судьба, лучше изобрести велосипед
public static File createTempFile(String prefix, String suffix) throws IOException
СУФФИКС!!!
evg_ever,
04 Февраля 2014
-
+140
Horse3,
04 Февраля 2014
-
+69
- 1
- 2
- 3
- 4
- 5
public List<ImportException> importFiles() {
Collection<ImportException> exceptions = new ArrayList<ImportException>();
/* весь метод exceptions ссылается на этот список */
return (List<ImportException>) exceptions;
}
Полиморфизм ёпт
evg_ever,
04 Февраля 2014
-
+142
- 1
Травля "kegdan`a" объявляется открытой.
Horse3,
04 Февраля 2014
-
+139
- 1
Я анально воспитываю "kegdan`a".
Horse3,
04 Февраля 2014