this is a challenge to techno"boss"

ryuken

ryuken

Master Sergeant of 2024cels - 🧑🏻‍🌾
Joined
Jun 10, 2024
Posts
9,345
Reputation
18,425
this is a challenge to the guy who calls himself technoboss i never saw you actually talk about programming or tech so how do you call yourself techno"boss"

the challenge is:
i want you to tell me the Lambda Functions, Type Traits and Templates and SFINAE of the following c++ code


#include <iostream>
#include <type_traits>

// Primary template for the trait, by default it returns false
template <typename, typename T>
struct has_to_string : std::false_type {};

// Specialization of the trait where substitution will succeed if the class T has a method `std::string to_string() const`
template <typename C>
struct has_to_string<C, std::string(C::*)() const> : std::true_type {};

// Helper template to deduce the function signature
template <typename C>
constexpr bool has_to_string_v = has_to_string<C, decltype(&C::to_string)>::value;

// Example classes
struct A {
std::string to_string() const { return "Class A"; }
};

struct B {
int to_string() const { return 42; } // Different return type, won't match std::string
};

struct C {
void foo() const {} // No `to_string` method at all
};

// Function that uses SFINAE to conditionally compile based on whether the class has a `to_string` method
template <typename T>
typename std::enable_if<has_to_string_v<T>, void>::type
print_to_string(const T& obj) {
std::cout << obj.to_string() << std::endl;
}

template <typename T>
typename std::enable_if<!has_to_string_v<T>, void>::type
print_to_string(const T&) {
std::cout << "No to_string method available" << std::endl;
}

int main() {
A a;
B b;
C c;

print_to_string(a); // Prints "Class A"
print_to_string(b); // Prints "No to_string method available"
print_to_string(c); // Prints "No to_string method available"

return 0;
}

the punishment if you fail: we will call you lil techno for a week

if you succeeded: i will make my banner whatever you want and i will make an apology thread and give my loyalty to you to the rest of my life
 
  • So Sad
  • +1
  • JFL
Reactions: itzyaboyJJ, Darkeningstar and n9wiff
@N9wiff•˚₊‧⋆. @itzyaboyJJ @Darkeningstar @Willmogulater
 
  • +1
  • Woah
  • JFL
Reactions: itzyaboyJJ, Darkeningstar and n9wiff
@Gaygymmaxx @Putin @cromagnon
 
  • So Sad
Reactions: n9wiff
@TechnoBoss revealed to me in PM's that he is classified as "illiterate" 😢
 
  • +1
  • JFL
Reactions: Clqs, itzyaboyJJ and ryuken
He probably likes techo music because hes edgy and shiet
 
  • JFL
Reactions: Darkeningstar, n9wiff, TechnoBoss and 1 other person
this is a challenge to the guy who calls himself technoboss i never saw you actually talk about programming or tech so how do you call yourself techno"boss"

the challenge is:
i want you to tell me the Lambda Functions, Type Traits and Templates and SFINAE of the following c++ code


#include <iostream>
#include <type_traits>

// Primary template for the trait, by default it returns false
template <typename, typename T>
struct has_to_string : std::false_type {};

// Specialization of the trait where substitution will succeed if the class T has a method `std::string to_string() const`
template <typename C>
struct has_to_string<C, std::string(C::*)() const> : std::true_type {};

// Helper template to deduce the function signature
template <typename C>
constexpr bool has_to_string_v = has_to_string<C, decltype(&C::to_string)>::value;

// Example classes
struct A {
std::string to_string() const { return "Class A"; }
};

struct B {
int to_string() const { return 42; } // Different return type, won't match std::string
};

struct C {
void foo() const {} // No `to_string` method at all
};

// Function that uses SFINAE to conditionally compile based on whether the class has a `to_string` method
template <typename T>
typename std::enable_if<has_to_string_v<T>, void>::type
print_to_string(const T& obj) {
std::cout << obj.to_string() << std::endl;
}

template <typename T>
typename std::enable_if<!has_to_string_v<T>, void>::type
print_to_string(const T&) {
std::cout << "No to_string method available" << std::endl;
}

int main() {
A a;
B b;
C c;

print_to_string(a); // Prints "Class A"
print_to_string(b); // Prints "No to_string method available"
print_to_string(c); // Prints "No to_string method available"

return 0;
}

the punishment if you fail: we will call you lil techno for a week

if you succeeded: i will make my banner whatever you want and i will make an apology thread and give my loyalty to you to the rest of my life
What the fuck is all this shit? I'm not doing any of this. I don't even know what the fuck you're talking about lol.

@TechnoBoss revealed to me in PM's that he is classified as "illiterate" 😢
No u

He probably likes techo music because hes edgy and shiet
It's not edgy to like techno music. I have techno in my name because I mix techno music on my FLX4 as a hobby.
 
  • JFL
  • +1
Reactions: Darkeningstar, try2beme, ryuken and 2 others
Power tripping subhuman dog
 
  • JFL
Reactions: Tabula Rasa and ryuken
What the fuck is all this shit? I'm not doing any of this. I don't even know what the fuck you're talking about lol.
Funny GIF
 
  • JFL
Reactions: ryuken
  • Woah
Reactions: itzyaboyJJ
What the fuck is all this shit? I'm not doing any of this. I don't even know what the fuck you're talking about lol.


No u


It's not edgy to like techno music. I have techno in my name because I mix techno music on my FLX4 as a hobby.
<a dog
 
Anyway, @TechnoBoss frauds less than that subhuman of @Darkeningstar
He is not a star, he is not "darkening", jfl edgy. He is a buffoon.
 
  • So Sad
Reactions: TechnoBoss, ryuken and itzyaboyJJ
Anyway, @TechnoBoss frauds less than that subhuman of @Darkeningstar
He is not a star, he is not "darkening", jfl edgy. He is a buffoon.
we love you bhai:(
 
  • JFL
Reactions: Darkeningstar
@TechnoBoss it was a joke thread btw
 
  • JFL
Reactions: itzyaboyJJ, Darkeningstar and TechnoBoss
It was an ironic post and I got 3 so sad
 
  • JFL
Reactions: ryuken

Similar threads

Clavicular
Replies
94
Views
3K
ivan.kuk
ivan.kuk
P
Replies
6
Views
482
dbva
dbva
Xangsane
Replies
102
Views
6K
notsocommonthumb
notsocommonthumb
Nazi Germany
Replies
22
Views
306
Favelacel
Favelacel
NZb6Air
Replies
123
Views
5K
nosecel (sec acc)
nosecel (sec acc)

Users who are viewing this thread

Back
Top