Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

btree requires key to be Default Constructibe #9

Open
GoogleCodeExporter opened this issue May 21, 2015 · 1 comment
Open

btree requires key to be Default Constructibe #9

GoogleCodeExporter opened this issue May 21, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

See summary. This is not required for ordinary std::set.

To reproduce:
$ cat bug.cpp 
#include "btree_set.h"
#include <set>

class Foo {
  int bar_;
public:
  explicit Foo(int bar): bar_(bar) {}
};

int main(void) {
  btree::btree_set<Foo> a;
  std::set<Foo> b;

  return 0;
}

$ clang++ bug.cpp -std=c++11 -stdlib=libc++
In file included from bug.cpp:1:
In file included from ./btree_set.h:27:
./btree.h:1402:55: error: no matching constructor for initialization of 
'key_type' (aka 'Foo')
      sizeof(key_compare_checker(key_compare_helper()(key_type(), key_type()))) ==
                                                      ^
./btree.h:161:31: note: expanded from macro 'COMPILE_ASSERT'
  typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
                              ^
./btree_container.h:32:20: note: in instantiation of template class 
'btree::btree<btree::btree_set_params<Foo, std::__1::less<Foo>, 
std::__1::allocator<Foo>, 256>>' requested here
  typedef typename Tree::params_type params_type;
                   ^
./btree_container.h:147:39: note: in instantiation of template class 
'btree::btree_container<btree::btree<btree::btree_set_params<Foo, 
std::__1::less<Foo>, std::__1::allocator<Foo>, 256>>>' requested here
class btree_unique_container : public btree_container<Tree> {
                                      ^
./btree_set.h:37:26: note: in instantiation of template class 
'btree::btree_unique_container<btree::btree<btree::btree_set_params<Foo, 
std::__1::less<Foo>, std::__1::allocator<Foo>, 256>>>' requested here
class btree_set : public btree_unique_container<
                         ^
bug.cpp:11:25: note: in instantiation of template class 'btree::btree_set<Foo, 
std::__1::less<Foo>, std::__1::allocator<Foo>, 256>' requested here
  btree::btree_set<Foo> a;
                        ^
bug.cpp:7:12: note: candidate constructor not viable: requires 1 argument, but 
0 were provided
  explicit Foo(int bar): bar_(bar) {}
           ^
bug.cpp:4:7: note: candidate constructor (the implicit copy constructor) not 
viable: requires 1 argument, but 0 were provided
class Foo {
      ^
bug.cpp:4:7: note: candidate constructor (the implicit move constructor) not 
viable: requires 1 argument, but 0 were provided
1 error generated.

$ clang -v
Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.2
Thread model: posix

Original issue reported on code.google.com by an...@korobeynikov.info on 14 Feb 2013 at 5:46

@GoogleCodeExporter
Copy link
Author

I suspect we could remove the CompileAssert and it would build. I'll talk to 
Peter about fixing this.

Original comment by josh.mac...@gmail.com on 21 Feb 2013 at 6:37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant