KK
namespace beast = boost::beast;
Size: a a a
KK
namespace beast = boost::beast;
KK
O
enum
и нескольких врапперов переизобрёл ссылки на константные статические строки...//! User-defined enum
enum class test {
first, second, third
};
//! We specialize some text
//! property for our enum
template<> constexpr inline auto vtp::representation<test::first> = "first value";
template<> constexpr inline auto vtp::representation<test::second> = "second value";
//! We declare simple text getter
template<test value> constexpr inline
auto text_value = vtp::static_converter<value>{};
//! Some method which accepts std::string
void foo(std::string s) {
std::cout << s << std::endl;
}
//! Some method which accepts light weight wrapper:
void bar(vtp::runtime_converter<test> rcv) {
foo(rcv);
}
int main() {
auto x = text_value<test::first>;
auto y = text_value<test::second>;
foo(x); // first value
bar(y); // second value
// Error! There isn't such specialization:
// auto z = text_value<test::third>;
}
inline std::string first = "first value";
inline std::string second = "second value";
O
O
O
O
O
D
//! User-defined enum
enum class test {
first, second, third
};
//! We specialize some text
//! property for our enum
template<> constexpr inline auto vtp::representation<test::first> = "first value";
template<> constexpr inline auto vtp::representation<test::second> = "second value";
//! We declare simple text getter
template<test value> constexpr inline
auto text_value = vtp::static_converter<value>{};
//! Some method which accepts std::string
void foo(std::string s) {
std::cout << s << std::endl;
}
//! Some method which accepts light weight wrapper:
void bar(vtp::runtime_converter<test> rcv) {
foo(rcv);
}
int main() {
auto x = text_value<test::first>;
auto y = text_value<test::second>;
foo(x); // first value
bar(y); // second value
// Error! There isn't such specialization:
// auto z = text_value<test::third>;
}
inline std::string first = "first value";
inline std::string second = "second value";
D
O
constexpr
-функции?D
D
o
D
o
O
D
//! User-defined enum
enum class test {
first, second, third
};
//! We specialize some text
//! property for our enum
template<> constexpr inline auto vtp::representation<test::first> = "first value";
template<> constexpr inline auto vtp::representation<test::second> = "second value";
//! We declare simple text getter
template<test value> constexpr inline
auto text_value = vtp::static_converter<value>{};
//! Some method which accepts std::string
void foo(std::string s) {
std::cout << s << std::endl;
}
//! Some method which accepts light weight wrapper:
void bar(vtp::runtime_converter<test> rcv) {
foo(rcv);
}
int main() {
auto x = text_value<test::first>;
auto y = text_value<test::second>;
foo(x); // first value
bar(y); // second value
// Error! There isn't such specialization:
// auto z = text_value<test::third>;
}
inline std::string first = "first value";
inline std::string second = "second value";
D
o