폰이라 코드 하이라이팅은 못함
#pragma once
#include
#include
#include
namespace
{
template std::string strize(T operand)
{
std::ostringstream stream;
stream << operand;
return stream.str();
}
template class Nullable
{
private:
T m_value;
bool m_hasValue;
public:
operator bool() const
{
return m_hasValue;
}
T operator()()
{
if (!m_hasValue) throw "InvalidOperationException";
else return m_value;
}
Nullable() : m_hasValue(false){}
T& operator=(T operand)
{
m_value = operand;
m_hasValue = true;
return m_value;
}
};
template std::string append(T first)
{
return strize(first);
}
template std::string append(T first, Ts ... rest)
{
return strization(first).append("\0").append(append(rest ...));
}
}
namespace memo
{
template auto memoize(Func func, Args ... args) -> decltype(func(args ...))
{
static std::unordered_map>> memory;
auto& pos = memory[&func][append(args ...)];
if (!pos) pos = func(args ...);
return pos();
}
}
#pragma once
#include
#include
#include
namespace
{
template std::string strize(T operand)
{
std::ostringstream stream;
stream << operand;
return stream.str();
}
template class Nullable
{
private:
T m_value;
bool m_hasValue;
public:
operator bool() const
{
return m_hasValue;
}
T operator()()
{
if (!m_hasValue) throw "InvalidOperationException";
else return m_value;
}
Nullable() : m_hasValue(false){}
T& operator=(T operand)
{
m_value = operand;
m_hasValue = true;
return m_value;
}
};
template std::string append(T first)
{
return strize(first);
}
template std::string append(T first, Ts ... rest)
{
return strization(first).append("\0").append(append(rest ...));
}
}
namespace memo
{
template auto memoize(Func func, Args ... args) -> decltype(func(args ...))
{
static std::unordered_map>> memory;
auto& pos = memory[&func][append(args ...)];
if (!pos) pos = func(args ...);
return pos();
}
}
- dc official App
대충 누가 짜놓은거 일부 복붙 한 느낌이 강함
니가 짠게 맞다면 이 코드를 무슨 목적으로 왜 만들었니?
일단 잘한거냐 못한거냐 - dc App