TmstsLocalTrain = packed record
_mem0000 : array [$0000..$0061] of byte;
// 0062
HeadWagon : dword; // Головная единица ПС
// 0066
TailWagon : dword; // Хвостовая единица ПС
// 006A
LocWagon : dword; // Управляемая игроком единица ПС
// 006E
_mem006E : dword;
// 0072
Caps : dword;
// 0076
_mem0076 : array [$0076..$0091] of byte;
// 0092
Speed : single; // Скорость по скоростемеру, м/с
// 0096
Acceleration : single; // Ускорение, м/с2
// 009A
_mem009A : array [$009A..$00D5] of byte;
// 00D6
TimeSec : single;
// 00DA
ReversingOdometer : single;
// 00DE
end;
struct Arr1 {
int length;
int data[100];
}
struct Arr1 someFunc() {}
struct Arr2 {
int length;
int* data; // не забудь free(arr.data);
}
struct Arr2 someFunc() {}
int sprintf ( char * str, const char * format, ... );
class Committer { // interface
public:
virtual void commit() = 0;
virtual ~Committer() = default;
}
enum class ErrCode { OK, UNCLONEABLE, BAD_RECIPIENT };
struct CommitObj {
ErrCode errCode;
std::unique_ptr<Committer> action;
}
class UiObj {
public:
virtual CommitObj startClone(std::shared_ptr<UiObj> recipient) = 0;
}
template <class T> struct string_traits;
template <class C, class T, class A>
struct string_traits<std::basic_string<C,T,A>> {
using Ch = C;
using Tr = T;
using Sv = std::basic_string_view<C,T>;
};
template <class C, class T>
struct string_traits<std::basic_string_view<C,T>> {
using Ch = C;
using Tr = T;
using Sv = std::basic_string_view<C,T>;
};
template <class C>
struct string_traits<const C*> {
using Ch = C;
using Tr = std::char_traits<C>;
using Sv = std::basic_string_view<C>;
};
template <class C, size_t N>
struct string_traits<C[N]> {
using Ch = C;
using Sv = std::basic_string_view<C>;
};
template<class S>
using s_v_t = typename string_traits<std::remove_cvref_t<S>>::Sv;
namespace detail {
template <class Sv>
Sv remainderSv(Sv s, Sv prefix)
{
if (s.length() <= prefix.length()
|| !s.starts_with(prefix))
return {};
return s.substr(prefix.length(), s.length() - prefix.length());
}
}
/// @brief remainderSv
/// Same for prefix only
template <class A>
inline auto remainderSv(const A& s, s_v_t<A> prefix) -> s_v_t<A>
{ return detail::remainderSv<s_v_t<A>>(s, prefix); }
class BuildCircle extends BuildShape
.Implicitly-declared move constructor
If no user-defined move constructors are provided for a class type (struct, class, or union), and all of the following is true:
- there are no user-declared copy constructors;
- there are no user-declared copy assignment operators;
- there are no user-declared move assignment operators;
- there is no user-declared destructor.
then the compiler will declare a move constructor as a non-explicit inline public member of its class with the signature T::T(T&&).
#include <iostream>
#include <memory>
#define IMPLEMENT_CLONE_1(Class, Keyword) \
virtual Class* vclone() const Keyword { return new Class(*this); } \
auto clone() const { return std::unique_ptr<Class>{vclone()}; }
#define IMPLEMENT_CLONE(Class) IMPLEMENT_CLONE_1(Class, override)
class BaseClass {
public:
IMPLEMENT_CLONE_1(BaseClass, )
virtual ~BaseClass() = default;
};
class MyClass : public BaseClass {
public:
IMPLEMENT_CLONE(MyClass)
void print() const { std::cout << "I'm a MyClass!" << std::endl; }
};
int main()
{
auto a = std::make_unique<MyClass>();
auto b = a->clone();
b->print();
return 0;
}
#include <iostream>
#include <memory>
class BaseClass {
public:
auto clone() const { return std::unique_ptr<BaseClass>{ vclone() }; }
protected:
virtual BaseClass* vclone() const { return new BaseClass(*this); }
};
template <class Super, class This>
class CloneImpl : public Super
{
public:
auto clone() const { return std::unique_ptr<This>{ static_cast<This*>(vclone()) }; }
protected:
CloneImpl* vclone() const override { return new This(*static_cast<const This*>(this)); }
};
class MyClass : public CloneImpl<BaseClass, MyClass> {
public:
void print() const { std::cout << "I'm a MyClass!" << std::endl; }
};
int main()
{
auto a = std::make_unique<MyClass>();
auto b = a->clone();
b->print();
return 0;
}
char x = 'FIO';
char x[] = "FIO";