-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprint.h
More file actions
54 lines (45 loc) · 1021 Bytes
/
Copy pathprint.h
File metadata and controls
54 lines (45 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
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
#pragma once
#include <cstdio>
#include <functional>
#include "string.h"
void operator"" _puts(const char * str, std::size_t)
{
printf("%s", str);
}
namespace Nuke{
struct PrintContext{
typedef const char * F;
F fmt;
PrintContext(F f) : fmt(f){
}
template <typename ... T>
void operator()(T&& ... args){
printf(fmt, std::forward<T>(args)...);
}
};
struct FmtContext{
typedef const char * F;
F fmt;
char * fp = nullptr;
FmtContext(F f) : fmt(f){
}
~FmtContext(){
delete fp;
}
template <typename ... T>
const char * operator()(T&& ... args){
Nuke::asprintf(&fp, fmt, std::forward<T>(args)...);
return (const char *)fp;
}
};
}
Nuke::PrintContext operator"" _print (const char * str, std::size_t)
{
return Nuke::PrintContext{str};
}
Nuke::FmtContext operator"" _fmt (const char * str, std::size_t)
{
return Nuke::FmtContext{str};
}
namespace Nuke{
}