Comments (3)
it would have been handled by the registry<Comps...>::add(apx::entity entity, const Comp& component) overload?
Unfortunately (?) not, it chooses the other overload. It can be slightly annoying because the overload resolution between const foo&
and foo&&
behaves differently depending on whether foo
is a template parameter or not, so one also has to be extra careful when refactoring code and transforming back or forth between a function and a function template...
colin@magic:/tmp/ramdisk> cat t.cpp
#include <string>
#include <iostream>
struct foo
{
template< typename T >
int bar( T&& )
{
std::cerr << "+++" << std::endl;
std::cerr << __PRETTY_FUNCTION__ << std::endl;
return 1;
}
template< typename T >
int bar( const T& )
{
std::cerr << "---" << std::endl;
std::cerr << __PRETTY_FUNCTION__ << std::endl;
return 2;
}
};
int main()
{
foo f;
std::string a;
const std::string b;
return f.bar( a ) + f.bar( std::move( a ) ) + f.bar( b );
}
colin@magic:/tmp/ramdisk> clang++ -Wall -Wextra -O3 -pedantic -std=c++17 t.cpp
colin@magic:/tmp/ramdisk> ./a.out
+++
int foo::bar(T &&) [T = std::__1::basic_string<char> &]
+++
int foo::bar(T &&) [T = std::__1::basic_string<char>]
---
int foo::bar(const T &) [T = std::__1::basic_string<char>]
from apecs.
I suspect I may have gotten away with this, since if I passed a some_component_type&
it would have been handled by the registry<Comps...>::add(apx::entity entity, const Comp& component)
overload? Nevertheless this is a very nice simplification.
from apecs.
Ahh I see, that example makes it very clear, thanks!
from apecs.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apecs.